DenseMatrix extends AbstractMatrix { @Override public SparseMatrix toSparse() { return (SparseMatrix) to(new SparseMatrixFactory()); } DenseMatrix(int rowCount, int columnCount, double[] values);  DenseMatrix(int rowCount, int columnCount);  DenseMatrix(int rowCount, int columnCount, Supplier<ByteBuffer> bufferSupplier);  DenseMatrix(Jama.Matrix matrix); double get(int i, int j); @Deprecated double getValue(int i, int j); @Override void set(int i, int j, double value); @Override void add(int i, int j, double value); @Override Element addAndGetElement(int i, int j, double value); @Override void reset(); @Override int getRowCount(); @Override int getColumnCount(); @Override LUDecomposition decomposeLU(); @Override Matrix times(Matrix other); @Override void iterateNonZeroValue(ElementHandler handler); @Override void iterateNonZeroValueOfColumn(int j, ElementHandler handler); @Override DenseMatrix toDense(); @Override SparseMatrix toSparse(); @Override Matrix to(MatrixFactory factory); @Override void print(PrintStream out); @Override void print(PrintStream out, List<String> rowNames, List<String> columnNames); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testToSparse() { DenseMatrix a = (DenseMatrix) createA(matrixFactory); SparseMatrix a2 = a.toSparse(); assertNotNull(a2); assertSame(a2, a2.toSparse()); DenseMatrix a3 = a2.toDense(); assertEquals(a, a3); }