@Test public void testGet() { for (int i = 0; i < A.length; ++i) { for (int j = 0; j < A[0].length; ++j) { assertTrue(matrixA.get(i, j).equals(A[i][j])); } } }
@Test public void testGetTransposed() { final Double[][] matrix = new Double[][] {{1.0, 2.0, 3.0}, {1.0, 2.0, 3.0}, {1.0, 2.0, 3.0}}; assertTrue(matrixA.getTransposed().equals(new SquareMatrix<Double>(matrix))); }
@Test public void testMultNumber() { final Double[][] matrix = new Double[][] {{2.0, 2.0, 2.0}, {4.0, 4.0, 4.0}, {6.0, 6.0, 6.0}}; assertTrue(matrixA.mult(2.0).equals(new SquareMatrix<Double>(matrix))); }
@Test public void testMultIMatrixOfNumber() { final Double[][] matrix = new Double[][] {{15.0, 15.0, 15.0}, {30.0, 30.0, 30.0}, {45.0, 45.0, 45.0}}; assertTrue(matrixA.mult(matrixB).equals(new SquareMatrix<Double>(matrix))); }
@Test public void testSub() { final Double[][] matrix = new Double[][] {{-3.0, -3.0, -3.0}, {-3.0, -3.0, -3.0}, {-3.0, -3.0, -3.0}}; assertTrue(matrixA.sub(matrixB).equals(new SquareMatrix<Double>(matrix))); }
@Test public void testAdd() { final Double[][] matrix = new Double[][] {{5.0, 5.0, 5.0}, {7.0, 7.0, 7.0}, {9.0, 9.0, 9.0}}; assertTrue(matrixA.add(matrixB).equals(new SquareMatrix<Double>(matrix))); }
@Test public void testGetRows() { assertTrue(matrixA.getRows() == A.length); }
@Test public void testGetColumns() { assertTrue(matrixA.getColumns() == A[0].length); }
@Test public void testEqualsObject() { final Double[][] a = new Double[][] {{1.0, 1.0, 1.0}, {2.0, 2.0, 2.0}, {3.0, 3.0, 3.0}}; assertTrue(matrixA.equals(new SquareMatrix<Double>(a))); assertFalse(matrixA.equals(matrixB)); }