return multiply(m2.invert());
}
public Matrix matrixOp(Matrix m2, String op) throws SyntaxException, UnbalancedParenthesesException, ParserException {
if (!new String("+-*/").contains(op))
throw new UndefinedOperationException(op + " is not defined for two matricies.", parser.getLastPlugin());
if (op.equalsIgnoreCase("*"))
return multiply(m2);
if (op.equalsIgnoreCase("/"))
return divide(m2);
if (!isRectangular || !m2.isRectangular || getRows() != m2.getRows() || getCols() != m2.getCols())
throw new UndefinedOperationException("Matrix " + (op.equals("+") ? "addition" : "subtraction") + " requires that the rows and the columns of the two matrices be equal.", parser.getLastPlugin());
Matrix m = new Matrix(getRows(), getCols());
for (int r = 0; r < m.getRows(); r++)
for (int c = 0; c < m.getCols(); c++)
m.set(get(r, c) + op + m2.get(r, c), r, c);
return m.compress();