MatrixAlgebra { public Matrix<?> divide(final Matrix<?> m1, final Matrix<?> m2) { Validate.notNull(m1, "m1"); Validate.notNull(m2, "m2"); Validate.isTrue(m1 instanceof DoubleMatrix2D, "Can only divide a 2D matrix"); Validate.isTrue(m2 instanceof DoubleMatrix2D, "Can only perform division with a 2D matrix"); return multiply(m1, getInverse(m2)); }  Matrix<?> add(final Matrix<?> m1, final Matrix<?> m2); Matrix<?> divide(final Matrix<?> m1, final Matrix<?> m2); Matrix<?> kroneckerProduct(final Matrix<?> m1, final Matrix<?> m2); abstract Matrix<?> multiply(final Matrix<?> m1, final Matrix<?> m2); Matrix<?> scale(final Matrix<?> m, final double scale); Matrix<?> subtract(final Matrix<?> m1, final Matrix<?> m2); abstract double getCondition(final Matrix<?> m); abstract double getDeterminant(final Matrix<?> m); abstract DoubleMatrix2D getInverse(final Matrix<?> m); abstract double getInnerProduct(final Matrix<?> m1, final Matrix<?> m2); abstract DoubleMatrix2D getOuterProduct(final Matrix<?> m1, final Matrix<?> m2); abstract double getNorm1(final Matrix<?> m); abstract double getNorm2(final Matrix<?> m); abstract double getNormInfinity(final Matrix<?> m); abstract DoubleMatrix2D getPower(final Matrix<?> m, final int p); abstract DoubleMatrix2D getPower(Matrix<?> m, double p); abstract double getTrace(final Matrix<?> m); abstract DoubleMatrix2D getTranspose(final Matrix<?> m); DoubleMatrix2D matrixTransposeMultiplyMatrix(DoubleMatrix2D a);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDivide1D() { ALGEBRA.divide(M1, M3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDivide2D() { ALGEBRA.divide(M3, M1); }