### Question:
Matrix { public Matrix addElementWise(final Matrix matrix) { return this.join(matrix, true, (l, r) -> l + r); } 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 matrixCannotBeAddedWithDifferentSizeMatrix() { final Matrix matrix1 = this.createMatrix(3, 2); final Matrix matrix2 = this.createMatrix(2, 3); ExceptionAssert.assertThrows( v -> matrix1.addElementWise(matrix2), IllegalArgumentException.class); ExceptionAssert.assertThrows( v -> matrix2.addElementWise(matrix1), IllegalArgumentException.class); }
@Test public void denseMatrixCanBeAddedWithSameSizeMatrix() { final Matrix matrix1 = this.createMatrix(3, 2, new double[] {2, 3, 5, 11, 1, 8}); final Matrix matrix2 = this.createMatrix(3, 2, new double[] {7, 3, 1, 5, 11, 9}); final Matrix result = matrix1.addElementWise(matrix2); MatcherAssert.assertThat( result, IsEqual.equalTo(this.createMatrix(3, 2, new double[] {9, 6, 6, 16, 12, 17}))); }