### Question:
DenseMatrix extends Matrix { public double[] getRaw() { return this.values; } DenseMatrix(final int rows, final int cols);  DenseMatrix(final int rows, final int cols, final double[] values); double[] getRaw(); @Override MatrixNonZeroElementRowIterator getNonZeroElementRowIterator(final int row); @Override String toString();  }### Answer:
@Test public void matrixCanBeInitializedWithDefaultValues() { final double[] values = new double[] {1, 4, 5, 7, 2, 3}; final DenseMatrix matrix = new DenseMatrix(2, 3, values); MatcherAssert.assertThat(matrix.getRowCount(), IsEqual.equalTo(2)); MatcherAssert.assertThat(matrix.getColumnCount(), IsEqual.equalTo(3)); MatcherAssert.assertThat(matrix.getElementCount(), IsEqual.equalTo(6)); MatcherAssert.assertThat(matrix.getRaw(), IsSame.sameInstance(values)); MatcherAssert.assertThat(matrix.getAt(0, 0), IsEqual.equalTo(1.0)); MatcherAssert.assertThat(matrix.getAt(0, 1), IsEqual.equalTo(4.0)); MatcherAssert.assertThat(matrix.getAt(0, 2), IsEqual.equalTo(5.0)); MatcherAssert.assertThat(matrix.getAt(1, 0), IsEqual.equalTo(7.0)); MatcherAssert.assertThat(matrix.getAt(1, 1), IsEqual.equalTo(2.0)); MatcherAssert.assertThat(matrix.getAt(1, 2), IsEqual.equalTo(3.0)); }
@Test public void rawVectorIsAccessible() { final DenseMatrix matrix = this.createMatrix(3, 2, new double[] {9.0, 3.2, 5.4, 1.2, 4.3, 7.6}); final boolean areEqual = Arrays.equals(matrix.getRaw(), new double[] {9.0, 3.2, 5.4, 1.2, 4.3, 7.6}); MatcherAssert.assertThat(areEqual, IsEqual.equalTo(true)); }
@Test public void rawVectorIsMutable() { final DenseMatrix matrix = this.createMatrix(3, 2, new double[] {9.0, 3.2, 5.4, 1.2, 4.3, 7.6}); matrix.setAt(0, 1, 12.1); final boolean areEqual = Arrays.equals(matrix.getRaw(), new double[] {9.0, 12.1, 5.4, 1.2, 4.3, 7.6}); MatcherAssert.assertThat(areEqual, IsEqual.equalTo(true)); }