All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.lsmp.djep.matrixJep.MatrixPreprocessor Maven / Gradle / Ivy

Go to download

JEP is a Java library for parsing and evaluating mathematical expressions.

The newest version!
/* @author rich
 * Created on 30-Oct-2003
 */
package org.lsmp.djep.matrixJep;
import org.nfunk.jep.*;
import org.nfunk.jep.function.*;
import org.lsmp.djep.djep.*;
import org.lsmp.djep.xjep.*;
import org.lsmp.djep.matrixJep.nodeTypes.*;
import org.lsmp.djep.vectorJep.*;
import org.lsmp.djep.vectorJep.function.*;
/**
 * This visitor does the majority of preprocessing work.
 * Specifically it
 * 
    *
  • Sets the dimension of each node. *
  • For assignment equations it adds an entry in the VariableTable *
  • For diff opperator it calculates the derivative. *
  • For the List opperator it finds the dimensions and * returns a ASTTensor. *
  • For the Hat opperator it finds the dimension and returns * a Power or Wedge opperator. *
* The visitor will return a new Tree. * * @author Rich Morris * Created on 30-Oct-2003 */ public class MatrixPreprocessor implements ParserVisitor { private MatrixJep mjep; private MatrixNodeFactory nf; private DSymbolTable vt; public MatrixPreprocessor() {} /** * Main entry point: pre-process a node. * @param node Top node of tree. * @param mdjep Reference to MatrixJep instance * @return A new tree with all preprocessing carried out. * @throws ParseException */ public MatrixNodeI preprocess(Node node,MatrixJep mdjep) throws ParseException { this.mjep=mdjep; this.nf=(MatrixNodeFactory) mdjep.getNodeFactory(); this.vt=(DSymbolTable) mdjep.getSymbolTable(); return (MatrixNodeI) node.jjtAccept(this,null); } /** * Returns an array of matrix nodes which are the results of visiting each child. */ public MatrixNodeI[] visitChildrenAsArray(Node node,Object data) throws ParseException { int nchild = node.jjtGetNumChildren(); MatrixNodeI children[] = new MatrixNodeI[nchild]; for(int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy