@@ -2,6 +2,8 @@ import test from 'ava'
22import path from 'path'
33
44const Matrix = require ( path . resolve ( __dirname , '..' , 'dist' , 'itkMatrix.js' ) )
5+ const getMatrixElement = require ( path . resolve ( __dirname , '..' , 'dist' , 'itkgetMatrixElement.js' ) )
6+ const setMatrixElement = require ( path . resolve ( __dirname , '..' , 'dist' , 'itksetMatrixElement.js' ) )
57
68test ( 'rows should have the same number of rows as passed into the constructor' , t => {
79 let matrix = new Matrix ( 2 , 3 )
@@ -40,6 +42,20 @@ test('setElement() should set elements of the matrix', t => {
4042 t . is ( matrix . data [ 3 ] , 5.0 )
4143} )
4244
45+ test ( 'setMatrixElement() should set elements of the matrix' , t => {
46+ let matrix = new Matrix ( 2 , 2 )
47+ matrix . setIdentity ( )
48+ let newMatrix = null
49+ newMatrix = setMatrixElement ( matrix , 0 , 0 , 2.0 )
50+ newMatrix = setMatrixElement ( newMatrix , 0 , 1 , 3.0 )
51+ newMatrix = setMatrixElement ( newMatrix , 1 , 0 , 4.0 )
52+ newMatrix = setMatrixElement ( newMatrix , 1 , 1 , 5.0 )
53+ t . is ( newMatrix . data [ 0 ] , 2.0 )
54+ t . is ( newMatrix . data [ 1 ] , 3.0 )
55+ t . is ( newMatrix . data [ 2 ] , 4.0 )
56+ t . is ( newMatrix . data [ 3 ] , 5.0 )
57+ } )
58+
4359test ( 'getElement() should get elements of the matrix' , t => {
4460 let matrix = new Matrix ( 2 , 2 )
4561 matrix . setElement ( 0 , 0 , 2.0 )
@@ -52,6 +68,18 @@ test('getElement() should get elements of the matrix', t => {
5268 t . is ( matrix . getElement ( 1 , 1 ) , 5.0 )
5369} )
5470
71+ test ( 'getMatrixElement() should get elements of the matrix' , t => {
72+ let matrix = new Matrix ( 2 , 2 )
73+ matrix . setElement ( 0 , 0 , 2.0 )
74+ matrix . setElement ( 0 , 1 , 3.0 )
75+ matrix . setElement ( 1 , 0 , 4.0 )
76+ matrix . setElement ( 1 , 1 , 5.0 )
77+ t . is ( getMatrixElement ( matrix , 0 , 0 ) , 2.0 )
78+ t . is ( getMatrixElement ( matrix , 0 , 1 ) , 3.0 )
79+ t . is ( getMatrixElement ( matrix , 1 , 0 ) , 4.0 )
80+ t . is ( getMatrixElement ( matrix , 1 , 1 ) , 5.0 )
81+ } )
82+
5583test ( 'passing a Matrix to the constructor should create a copy' , t => {
5684 let matrix = new Matrix ( 2 , 2 )
5785 matrix . setElement ( 0 , 0 , 2.0 )
0 commit comments