- Notifications
You must be signed in to change notification settings - Fork20k
Closed
Description
The matrix class and the tests written for it only support shallow comparison. In other words, comparisons only verify whether two matrices have the same reference rather than actually comparing each element in the matrix.
int[][]data = { {1,2,3,4 }, {5,6,7,8 } };int[][]zeroData = { {0,0,0,0 }, {0,0,0,0 } };Matrixmatrix =newMatrix(data);MatrixzeroMatrix =newMatrix(zeroData);System.out.println(matrix);System.out.println(matrix.plus(zeroMatrix));System.out.println(matrix.equals(matrix.plus(zeroMatrix)));
The above equality should equate totrue
, since a matrix plus the zero matrix is itself (identity property of matrix addition), but instead, it equates tofalse
. Deep comparison is necessary, in the same way a deep copy of the data is made in the matrix constructor.
Metadata
Metadata
Assignees
Labels
No labels