### Question:
Matrix { public Collection<Integer> normalizeColumns() { final double[] columnSums = this.getColumnSums(Math::abs); final List<Integer> zeroColumns = new ArrayList<>(); for (int i = 0; i < this.numCols; i++) { if (0 == columnSums[i]) { zeroColumns.add(i); } } this.forEach( (row, col, value, setter) -> { final double sum = columnSums[col]; if (0 == sum) { return; } setter.accept(value / sum); }); return zeroColumns; } protected  Matrix(final int numRows, final int numCols); final int getElementCount(); final int getRowCount(); final int getColumnCount(); final double getAt(final int row, final int col); final void setAt(final int row, final int col, final double val); final void incrementAt(final int row, final int col, final double val); final ColumnVector getRowSumVector(); final ColumnVector getColumnSumVector(); Collection<Integer> normalizeColumns(); void removeNegatives(); void removeLessThan(final double minValue); final void scale(final double scale); Matrix multiplyElementWise(final Matrix matrix); Matrix addElementWise(final Matrix matrix); final double absSum(); final double sum(); ColumnVector multiply(final ColumnVector vector); final Matrix transpose(); Matrix roundTo(final int numPlaces); Matrix multiply(final double scalar); Matrix add(final double scalar); Matrix abs(); Matrix sqrt(); final boolean isSameSize(final Matrix matrix); final boolean isZeroMatrix(); @Override int hashCode(); @Override boolean equals(final Object obj); void forEach(final ReadOnlyElementVisitorFunction func); abstract MatrixNonZeroElementRowIterator getNonZeroElementRowIterator(final int row);  }### Answer:
@Test public void allDenseMatrixColumnsCanBeNormalized() { final Matrix matrix = this.createMatrix(3, 2, new double[] {2, 11, 3, 1, 5, 8}); final Collection<Integer> zeroColumnIndexes = matrix.normalizeColumns(); MatcherAssert.assertThat( matrix, IsEqual.equalTo(this.createMatrix(3, 2, new double[] {0.2, 0.55, 0.3, 0.05, 0.5, 0.4}))); MatcherAssert.assertThat(zeroColumnIndexes, IsEqual.equalTo(Collections.emptyList())); }
@Test public void zeroMatrixCanBeNormalized() { final Matrix matrix = this.createMatrix(2, 3); final Collection<Integer> zeroColumnIndexes = matrix.normalizeColumns(); MatcherAssert.assertThat( matrix, IsEqual.equalTo(this.createMatrix(2, 3, new double[] {0, 0, 0, 0, 0, 0}))); MatcherAssert.assertThat(zeroColumnIndexes, IsEqual.equalTo(Arrays.asList(0, 1, 2))); }
@Test public void matrixWithZeroSumColumnsCanBeNormalized() { final Matrix matrix = this.createMatrix(2, 3, new double[] {2, 0, 0, 0, -2, 0}); final Collection<Integer> zeroColumnIndexes = matrix.normalizeColumns(); MatcherAssert.assertThat( matrix, IsEqual.equalTo(this.createMatrix(2, 3, new double[] {1, 0, 0, 0, -1, 0}))); MatcherAssert.assertThat(zeroColumnIndexes, IsEqual.equalTo(Collections.singletonList(2))); }