SparseFieldMatrix extends AbstractFieldMatrix<T> { @Override public FieldMatrix<T> copy() { return new SparseFieldMatrix<T>(this); } SparseFieldMatrix(final Field<T> field);  SparseFieldMatrix(final Field<T> field,
                             final int rowDimension, final int columnDimension);  SparseFieldMatrix(SparseFieldMatrix<T> other);  SparseFieldMatrix(FieldMatrix<T> other); @Override void addToEntry(int row, int column, T increment); @Override FieldMatrix<T> copy(); @Override FieldMatrix<T> createMatrix(int rowDimension, int columnDimension); @Override int getColumnDimension(); @Override T getEntry(int row, int column); @Override int getRowDimension(); @Override void multiplyEntry(int row, int column, T factor); @Override void setEntry(int row, int column, T value);  }
@Test public void testCopyFunctions() { SparseFieldMatrix<Fraction> m1 = createSparseMatrix(testData); FieldMatrix<Fraction> m2 = m1.copy(); Assert.assertEquals(m1.getClass(), m2.getClass()); Assert.assertEquals((m2), m1); SparseFieldMatrix<Fraction> m3 = createSparseMatrix(testData); FieldMatrix<Fraction> m4 = m3.copy(); Assert.assertEquals(m3.getClass(), m4.getClass()); Assert.assertEquals((m4), m3); }
@Test public void testEqualsAndHashCode() { SparseFieldMatrix<Fraction> m = createSparseMatrix(testData); SparseFieldMatrix<Fraction> m1 = (SparseFieldMatrix<Fraction>) m.copy(); SparseFieldMatrix<Fraction> mt = (SparseFieldMatrix<Fraction>) m.transpose(); Assert.assertTrue(m.hashCode() != mt.hashCode()); Assert.assertEquals(m.hashCode(), m1.hashCode()); Assert.assertEquals(m, m); Assert.assertEquals(m, m1); Assert.assertFalse(m.equals(null)); Assert.assertFalse(m.equals(mt)); Assert.assertFalse(m.equals(createSparseMatrix(bigSingular))); }