org.lsmp.djep.matrixJep.function
Class MAssign

java.lang.Object
  extended by org.nfunk.jep.function.PostfixMathCommand
      extended by org.nfunk.jep.function.Assign
          extended by org.lsmp.djep.matrixJep.function.MAssign
All Implemented Interfaces:
MatrixSpecialEvaluationI, SpecialPreProcessorI, CallbackEvaluationI, PostfixMathCommandI

public class MAssign
extends Assign
implements MatrixSpecialEvaluationI, SpecialPreProcessorI

A matrix enabled assignment function. The lhs of an assignment must be a variable.

Author:
Rich Morris Created on 23-Feb-2004

Field Summary
 
Fields inherited from class org.nfunk.jep.function.PostfixMathCommand
curNumberOfParameters, numberOfParameters
 
Constructor Summary
MAssign()
           
 
Method Summary
 MatrixValueI evaluate(MatrixNodeI node, MatrixEvaluator visitor, MatrixJep j)
          A special methods for evaluating an assignment.
 MatrixNodeI preprocess(ASTFunNode node, MatrixPreprocessor visitor, MatrixJep mjep, MatrixNodeFactory nf)
          Subverts the preprocessing stage.
 void run(java.util.Stack s)
          The run method should not be called.
 
Methods inherited from class org.nfunk.jep.function.Assign
evaluate
 
Methods inherited from class org.nfunk.jep.function.PostfixMathCommand
checkNumberOfParameters, checkStack, getNumberOfParameters, setCurNumberOfParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MAssign

public MAssign()
Method Detail

run

public void run(java.util.Stack s)
         throws ParseException
The run method should not be called. Use evaluate(org.lsmp.djep.matrixJep.nodeTypes.MatrixNodeI, org.lsmp.djep.matrixJep.MatrixEvaluator, org.lsmp.djep.matrixJep.MatrixJep) instead.

Specified by:
run in interface PostfixMathCommandI
Overrides:
run in class PostfixMathCommand
Throws:
ParseException

evaluate

public MatrixValueI evaluate(MatrixNodeI node,
                             MatrixEvaluator visitor,
                             MatrixJep j)
                      throws ParseException
A special methods for evaluating an assignment. When an assignment is encountered, first evaluate the rhs. Then set the value of the lhs to the result.

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

preprocess

public MatrixNodeI preprocess(ASTFunNode node,
                              MatrixPreprocessor visitor,
                              MatrixJep mjep,
                              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.
mjep - 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.


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