### Question:
SparseMatrix implements Matrix<SparseMatrixRow> { @Override public Iterator<SparseMatrixRow> iterator() { return new SparseMatrixIterator(); } SparseMatrix(File path); long lastModified(); @Override SparseMatrixRow getRow(int rowId); @Override int[] getRowIds(); @Override int getNumRows(); ValueConf getValueConf(); @Override Iterator<SparseMatrixRow> iterator(); void close(); @Override File getPath(); static final Logger LOG; static final int DEFAULT_HEADER_SIZE; static final int FILE_HEADER; }### Answer:
@Test public void testWrite() throws IOException { File tmp = File.createTempFile("matrix", null); SparseMatrixWriter.write(tmp, srcRows.iterator()); }
@Test public void testReadWrite() throws IOException { File tmp = File.createTempFile("matrix", null); SparseMatrixWriter.write(tmp, srcRows.iterator()); Matrix m1 = new SparseMatrix(tmp); Matrix m2 = new SparseMatrix(tmp); }
@Test public void testTranspose() throws IOException { for (int numOpenPages: new int[] { 1, Integer.MAX_VALUE}) { File tmp1 = File.createTempFile("matrix", null); File tmp2 = File.createTempFile("matrix", null); File tmp3 = File.createTempFile("matrix", null); SparseMatrixWriter.write(tmp1, srcRows.iterator()); SparseMatrix m = new SparseMatrix(tmp1); verifyIsSourceMatrix(m); new SparseMatrixTransposer(m, tmp2, 1).transpose(); SparseMatrix m2 = new SparseMatrix(tmp2); new SparseMatrixTransposer(m2, tmp3, 1).transpose(); Matrix m3 = new SparseMatrix(tmp3); verifyIsSourceMatrixUnordered(m3, .001); } }
@Test public void testRows() throws IOException { for (int numOpenPages: new int[] { 1, Integer.MAX_VALUE}) { File tmp = File.createTempFile("matrix", null); SparseMatrixWriter.write(tmp, srcRows.iterator()); Matrix m = new SparseMatrix(tmp); verifyIsSourceMatrix(m); } }