Package lipstone.joshua.parser.exceptions

Examples of lipstone.joshua.parser.exceptions.UndefinedOperationException


            current.replaceCar(new ConsCell("{M" + (currentEqn.matrices.size() - 1) + "}", ConsType.OBJECT));
            forward = false;
          }
          else if (current.getCarType() == ConsType.NUMBER && second.getCarType() == ConsType.OBJECT) {
            if (operator == '/')
              throw new UndefinedOperationException(operator + " is not defined for a matrix and a scalar.", lastPlugin);
            Matrix m = currentEqn.matrices.get(Integer.parseInt(((String) current.getCar()).substring(2, ((String) current.getCar()).length() - 1)));
            Matrix result = m.scalarOp((BigDec) current.getCar(), new Character(operator).toString());
            currentEqn.matrices.add(result);
            second.remove();
            current.getNextConsCell().remove();
View Full Code Here


    return scalarOp(scalar, "/");
  }
 
  public Matrix scalarOp(BigDec scalar, String op) throws SyntaxException, UnbalancedParenthesesException, ParserException {
    if (!new String("*/").contains(op))
      throw new UndefinedOperationException(op + " is not defined for a matrix and a scalar.", parser.getLastPlugin());
    Matrix temp = new Matrix(this);
    for (int r = 0; r < temp.getRows(); r++)
      for (int c = 0; c < temp.matrix[r].length; c++)
        temp.set(temp.get(r, c) + op + scalar, r, c);
    return temp.compress();
View Full Code Here

    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();
View Full Code Here

TOP

Related Classes of lipstone.joshua.parser.exceptions.UndefinedOperationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.