@Test public void testSparseCopy() { SparseMatrix matrix = createSparseMatrixWithEmptyRow(); Matrix copy = matrix.clone(); assertSame("wrong class", copy.getClass(), matrix.getClass()); SparseMatrix castedCopy = (SparseMatrix) copy; Iterator<MatrixSlice> originalSlices = matrix.iterator(); Iterator<MatrixSlice> copySlices = castedCopy.iterator(); while (originalSlices.hasNext() && copySlices.hasNext()) { MatrixSlice originalSlice = originalSlices.next(); MatrixSlice copySlice = copySlices.next(); assertEquals("Wrong row indices.", originalSlice.index(), copySlice.index()); assertEquals("Slices are not equal.", originalSlice, copySlice); } assertSame("Number of rows of original and copy are not equal.", originalSlices.hasNext(), copySlices.hasNext()); }
@Override public Matrix clone() { SparseMatrix clone = new SparseMatrix(numRows(), numCols()); for (MatrixSlice slice : this) { clone.rowVectors.put(slice.index(), slice.clone()); } return clone; }
SparseMatrix extends AbstractMatrix { @Override public Matrix clone() { SparseMatrix clone = new SparseMatrix(numRows(), numCols()); for (MatrixSlice slice : this) { clone.rowVectors.put(slice.index(), slice.clone()); } return clone; } }
SparseMatrix extends AbstractMatrix { @Override public Matrix clone() { SparseMatrix clone = new SparseMatrix(numRows(), numCols()); for (MatrixSlice slice : this) { clone.rowVectors.put(slice.index(), slice.clone()); } return clone; } SparseMatrix(int rows, int columns, Map<Integer, Vector> rowVectors);  SparseMatrix(int rows, int columns, Map<Integer, Vector> rowVectors, boolean shallow);  SparseMatrix(int rows, int columns); }
SparseMatrix extends AbstractMatrix { @Override public Matrix clone() { SparseMatrix clone = new SparseMatrix(numRows(), numCols()); for (MatrixSlice slice : this) { clone.rowVectors.put(slice.index(), slice.clone()); } return clone; } SparseMatrix(int rows, int columns, Map<Integer, Vector> rowVectors);  SparseMatrix(int rows, int columns, Map<Integer, Vector> rowVectors, boolean shallow);  SparseMatrix(int rows, int columns); @Override Matrix clone(); @Override int numSlices(); Iterator<MatrixSlice> iterateNonEmpty(); @Override double getQuick(int row, int column); @Override Matrix like(); @Override Matrix like(int rows, int columns); @Override void setQuick(int row, int column, double value); @Override int[] getNumNondefaultElements(); @Override Matrix viewPart(int[] offset, int[] size); @Override Matrix assign(Matrix other, DoubleDoubleFunction function); @Override Matrix assignColumn(int column, Vector other); @Override Matrix assignRow(int row, Vector other); @Override Vector viewRow(int row); IntArrayList nonZeroRowIndices(); @Override MatrixFlavor getFlavor(); }
SparseMatrix extends AbstractMatrix { @Override public Matrix clone() { SparseMatrix clone = new SparseMatrix(numRows(), numCols()); for (MatrixSlice slice : this) { clone.rowVectors.put(slice.index(), slice.clone()); } return clone; } SparseMatrix(int rows, int columns, Map<Integer, Vector> rowVectors);  SparseMatrix(int rows, int columns, Map<Integer, Vector> rowVectors, boolean shallow);  SparseMatrix(int rows, int columns); @Override Matrix clone(); @Override int numSlices(); Iterator<MatrixSlice> iterateNonEmpty(); @Override double getQuick(int row, int column); @Override Matrix like(); @Override Matrix like(int rows, int columns); @Override void setQuick(int row, int column, double value); @Override int[] getNumNondefaultElements(); @Override Matrix viewPart(int[] offset, int[] size); @Override Matrix assign(Matrix other, DoubleDoubleFunction function); @Override Matrix assignColumn(int column, Vector other); @Override Matrix assignRow(int row, Vector other); @Override Vector viewRow(int row); IntArrayList nonZeroRowIndices(); @Override MatrixFlavor getFlavor();  }