Package lipstone.joshua.parser.types

Examples of lipstone.joshua.parser.types.Matrix


   
    do {
      if (current.getCarType() == ConsType.CONS_CELL)
        current.replaceCar(preProcess((ConsCell) current.getCar()));
      if (current.getCarType() == ConsType.OBJECT && ((String) current.getCar()).startsWith("{[")) {
        currentEqn.matrices.add(new Matrix((String) current.getCar()));
        current.replaceCar(new ConsCell("{M" + (currentEqn.matrices.size() - 1) + "}", ConsType.OBJECT));
      }
    } while (!((current = current.getNextConsCell()).isNull())); //This steps current forward while checking for nulls
    current = input;
   
View Full Code Here


            second.remove();
            current.getNextConsCell().remove();
            forward = false;
          }
          else if (current.getCarType() == ConsType.OBJECT && second.getCarType() == ConsType.OBJECT) {
            Matrix m1 = currentEqn.matrices.get(Integer.parseInt(((String) current.getCar()).substring(2, ((String) current.getCar()).length() - 1)));
            Matrix m2 = currentEqn.matrices.get(Integer.parseInt(((String) second.getCar()).substring(2, ((String) second.getCar()).length() - 1)));
            Matrix result = m1.matrixOp(m2, new Character(operator).toString());
            currentEqn.matrices.add(result);
            second.remove();
            current.getNextConsCell().remove();
            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();
            current.replaceCar(new ConsCell("{M" + (currentEqn.matrices.size() - 1) + "}", ConsType.OBJECT));
            forward = false;
          }
          else if (current.getCarType() == ConsType.OBJECT && second.getCarType() == ConsType.NUMBER) {
            Matrix m = currentEqn.matrices.get(Integer.parseInt(((String) second.getCar()).substring(2, ((String) second.getCar()).length() - 1)));
            Matrix result = m.scalarOp((BigDec) second.getCar(), new Character(operator).toString());
            currentEqn.matrices.add(result);
            second.remove();
            current.getNextConsCell().remove();
            current.replaceCar(new ConsCell("{M" + (currentEqn.matrices.size() - 1) + "}", ConsType.OBJECT));
            forward = false;
View Full Code Here

 
  private void parseMatrices(String input) throws ParserException {
    if (input.contains("{"))
      input = input.substring(input.indexOf("{"));
    while (input.contains("}")) {
      matrices.add(new Matrix(input.substring(0, input.indexOf("}"))));
      if (input.indexOf("{", input.indexOf("}")) >= 0)
        input = input.substring(input.indexOf("{", input.indexOf("}")));
      else
        break;
    }
View Full Code Here

TOP

Related Classes of lipstone.joshua.parser.types.Matrix

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.