### Question:
SparseMatrix extends Matrix { public int getNonZeroColumnCount(final int row) { return this.maxIndices[row]; } SparseMatrix(final int numRows, final int numCols, final int initialCapacityPerRow); @Override final void forEach(final ReadOnlyElementVisitorFunction func); @Override MatrixNonZeroElementRowIterator getNonZeroElementRowIterator(final int row); int getNonZeroColumnCount(final int row); int getRowCapacity(final int row); @Override String toString(); int getNumEntries();  }### Answer:
@Test public void entryCanBeRemoved() { final SparseMatrix sparseMatrix = this.createMatrix(3, 2, new double[] {2, 3, 5, 11, 1, 8}); MatcherAssert.assertThat(sparseMatrix.getNonZeroColumnCount(0), IsEqual.equalTo(2)); sparseMatrix.setAt(0, 1, 0.0); MatcherAssert.assertThat(sparseMatrix.getNonZeroColumnCount(0), IsEqual.equalTo(1)); MatcherAssert.assertThat( sparseMatrix, IsEqual.equalTo(this.createMatrix(3, 2, new double[] {2, 0, 5, 11, 1, 8}))); }
@Test public void entryCanBeRemovedWhenValuesAreAddedOutOfOrder() { final SparseMatrix sparseMatrix = this.createMatrix(3, 2); final int numRows = 3; final int numCols = 2; final double[] values = new double[] {2, 3, 5, 11, 1, 8}; for (int r = 0; r < numRows; ++r) { for (int c = 0; c < numCols; ++c) { final int r2 = numRows - r - 1; final int c2 = numCols - c - 1; sparseMatrix.setAt(r2, c2, values[r2 * numCols + c2]); } } MatcherAssert.assertThat(sparseMatrix.getNonZeroColumnCount(0), IsEqual.equalTo(2)); sparseMatrix.setAt(0, 1, 0.0); MatcherAssert.assertThat(sparseMatrix.getNonZeroColumnCount(0), IsEqual.equalTo(1)); MatcherAssert.assertThat( sparseMatrix, IsEqual.equalTo(this.createMatrix(3, 2, new double[] {2, 0, 5, 11, 1, 8}))); }
@Test public void lastEntryInRowCanBeRemoved() { final SparseMatrix sparseMatrix = this.createMatrix(3, 2, new double[] {2, 3, 5, 11, 1, 8}); MatcherAssert.assertThat(sparseMatrix.getNonZeroColumnCount(0), IsEqual.equalTo(2)); sparseMatrix.setAt(0, 1, 0.0); sparseMatrix.setAt(0, 0, 0.0); MatcherAssert.assertThat(sparseMatrix.getNonZeroColumnCount(0), IsEqual.equalTo(0)); MatcherAssert.assertThat( sparseMatrix, IsEqual.equalTo(this.createMatrix(3, 2, new double[] {0, 0, 5, 11, 1, 8}))); }