@Test public void test_constructor() { for (int l = 0; l < m.nlines(); l++) { for (int c = 0; c < m.ncols(); c++) { assertArrayEquals( new Integer[] {(int) l, (int) c, dok.get(l, c)}, new Integer[] {(int) l, (int) c, m.get(l, c)}); } } }
@Test public void testMultiplyI() { DOK1Dint vec = new DOK1Dint(m.ncols()); vec.set(0, 1); vec.set(9, (int) 66.6); vec.set(3, (int) 6.9); vec.set(3, 0); assertEquals(vec, m.multiply(vec)); }
@Test public void testGet() { assertEquals(1, m.get(1, 1), 0); DOK2Dint dok = new DOK2Dint(10, 10); // first line == [0 1 2 3 4 5 ... ] for (int c = 0; c < dok.ncols(); c++) { dok.set(0, c, c); } // first col == [0 1.5 2.5 3.5 ...] for (int l = 1; l < dok.nlines(); l++) { dok.set(l, 0, (int) (l + 0.5)); } Matrix2Dint m = new CSC2Dint(dok); for (int l = 0; l < m.nlines(); l++) { for (int c = 0; c < m.ncols(); c++) { // print line and column number on error assertArrayEquals( new Integer[] {(int) l, (int) c, dok.get(l, c)}, new Integer[] {(int) l, (int) c, m.get(l, c)}); } } }
@Test public void testNz_elements() { assertEquals(m.nnz(), m.nz_elements().size()); }