org.lsmp.djep.matrixJep.function
Class MMap

java.lang.Object
  extended by org.nfunk.jep.function.PostfixMathCommand
      extended by org.lsmp.djep.vectorJep.function.VMap
          extended by org.lsmp.djep.matrixJep.function.MMap
All Implemented Interfaces:
MatrixSpecialEvaluationI, SpecialPreProcessorI, NaryOperatorI, CallbackEvaluationI, PostfixMathCommandI

public class MMap
extends VMap
implements SpecialPreProcessorI, MatrixSpecialEvaluationI

Author:
Rich Morris Created on 14-Feb-2005

Field Summary
 
Fields inherited from class org.nfunk.jep.function.PostfixMathCommand
curNumberOfParameters, numberOfParameters
 
Constructor Summary
MMap()
           
 
Method Summary
 MatrixValueI evaluate(MatrixNodeI node, MatrixEvaluator visitor, MatrixJep jep)
          Returns the result of evaluating this node and the tree below.
 MatrixNodeI preprocess(ASTFunNode node, MatrixPreprocessor visitor, MatrixJep jep, MatrixNodeFactory nf)
          Subverts the preprocessing stage.
 
Methods inherited from class org.lsmp.djep.vectorJep.function.VMap
calcDim, calcValue, checkNumberOfParameters, evaluate, getVars
 
Methods inherited from class org.nfunk.jep.function.PostfixMathCommand
checkStack, getNumberOfParameters, run, setCurNumberOfParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.nfunk.jep.function.PostfixMathCommandI
getNumberOfParameters, run, setCurNumberOfParameters
 

Constructor Detail

MMap

public MMap()
Method Detail

preprocess

public MatrixNodeI preprocess(ASTFunNode node,
                              MatrixPreprocessor visitor,
                              MatrixJep jep,
                              MatrixNodeFactory nf)
                       throws ParseException
Description copied from interface: SpecialPreProcessorI
Subverts the preprocessing stage. Preprocessing performs a number of operations:
  1. Converts each node into one of the subtypes of MatrixNodeI
  2. Calculate the dimensions for the results
  3. Performs any special symbolic operations such as differentation
In general the first step in preprocessing is to run the preprocessor on the children of the node. This can be done using
 MatrixNodeI children[] = visitor.visitChildrenAsArray(node,null);
 
The final step is to construct a node of the correct type. The MatrixNodeFactory argument has a number of methods to do this. For example
 return (ASTMFunNode) nf.buildOperatorNode(node.getOperator(),children,rhsDim);
 
Note how the dimension is specified.

Specified by:
preprocess in interface SpecialPreProcessorI
Parameters:
node - the top node of the tree representing the function and its arguments.
visitor - A reference to the preprocessing visitor.
jep - A reference of the MatrixJep instance.
nf - A reference to the node factory object.
Returns:
A new MatrixNodeI representing the converted function.
Throws:
ParseException - if some error occurs.

evaluate

public MatrixValueI evaluate(MatrixNodeI node,
                             MatrixEvaluator visitor,
                             MatrixJep jep)
                      throws ParseException
Description copied from interface: MatrixSpecialEvaluationI
Returns the result of evaluating this node and the tree below. This method has the responsibility for evaluating the children of the node and it should generally call
 MatrixValueI val = (MatrixValueI) node.jjtGetChild(i).jjtAccept(visitor,null); 
 
for each child.

The final results should be copied into the mvalue field of the node using

 MatrixValueI mvalue = node.getMValue();
 mvalue.setEles(res);
 return mvalue;
 

Specified by:
evaluate in interface MatrixSpecialEvaluationI
Parameters:
node - The top node.
visitor - The parser visitor
jep - The current MatrixJep instance.
Returns:
Value after evaluation.
Throws:
ParseException


http://www.singularsys.com/jep Copyright © 2007 Singular Systems