//------------------------------------------------------------------------- public virtual void test_get() { double[][] @base = new double[][] { new double[] { 1d, 2d }, new double[] { 3d, 4d }, new double[] { 5d, 6d } }; DoubleMatrix test = DoubleMatrix.copyOf(@base); assertEquals(test.get(0, 0), 1d); assertEquals(test.get(2, 1), 6d); assertThrows(() => test.get(-1, 0), typeof(System.IndexOutOfRangeException)); assertThrows(() => test.get(0, 4), typeof(System.IndexOutOfRangeException)); }
//------------------------------------------------------------------------- private void assertMatrix(DoubleMatrix matrix, params double[] expected) { if (expected.Length == 0) { assertSame(matrix, DoubleMatrix.EMPTY); assertEquals(matrix.Empty, true); } else { assertEquals(matrix.size(), expected.Length); int rowCount = matrix.rowCount(); int colCount = matrix.columnCount(); double[][] array = matrix.toArrayUnsafe(); double[][] array2 = matrix.toArray(); assertTrue(Arrays.deepEquals(array, array2)); for (int i = 0; i < rowCount; i++) { for (int j = 0; j < colCount; j++) { assertEquals(matrix.get(i, j), expected[i * colCount + j]); assertEquals(array[i][j], expected[i * colCount + j]); } } assertEquals(matrix.dimensions(), 2); assertEquals(matrix.Empty, false); assertEquals(matrix.Square, matrix.rowCount() == matrix.columnCount()); } }