### Question:
MatrixAlgebra { public Matrix scale(Matrix m, double scale) { ArgChecker.notNull(m, "m"); if (m instanceof DoubleArray) { return ((DoubleArray) m).multipliedBy(scale); } else if (m instanceof DoubleMatrix) { return ((DoubleMatrix) m).multipliedBy(scale); } throw new UnsupportedOperationException(); }  Matrix add(Matrix m1, Matrix m2); Matrix divide(Matrix m1, Matrix m2); Matrix kroneckerProduct(Matrix m1, Matrix m2); abstract Matrix multiply(Matrix m1, Matrix m2); Matrix scale(Matrix m, double scale); Matrix subtract(Matrix m1, Matrix m2); abstract double getCondition(Matrix m); abstract double getDeterminant(Matrix m); abstract DoubleMatrix getInverse(Matrix m); abstract double getInnerProduct(Matrix m1, Matrix m2); abstract DoubleMatrix getOuterProduct(Matrix m1, Matrix m2); abstract double getNorm1(Matrix m); abstract double getNorm2(Matrix m); abstract double getNormInfinity(Matrix m); abstract DoubleMatrix getPower(Matrix m, int p); abstract DoubleMatrix getPower(Matrix m, double p); abstract double getTrace(Matrix m); abstract DoubleMatrix getTranspose(Matrix m); DoubleMatrix matrixTransposeMultiplyMatrix(DoubleMatrix a);  }### Answer:
@Test public void testScaleWrongType() { assertThatExceptionOfType(UnsupportedOperationException.class) .isThrownBy(() -> ALGEBRA.scale(M5, 0.5)); }
@Test public void testScale() { Matrix m = ALGEBRA.scale(M1, 10); assertThat(m instanceof DoubleArray).isTrue(); assertMatrixEquals(m, DoubleArray.of(10, 20)); m = ALGEBRA.scale(m, 0.1); assertMatrixEquals(m, M1); m = ALGEBRA.scale(M3, 10); assertThat(m instanceof DoubleMatrix).isTrue(); assertMatrixEquals(m, DoubleMatrix.of(2, 2, 10d, 20d, 30d, 40d)); m = ALGEBRA.scale(m, 0.1); assertMatrixEquals(m, M3); }