org.lsmp.djep.vectorJep.function
Class VMap

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

public class VMap
extends PostfixMathCommand
implements NaryOperatorI, CallbackEvaluationI

evaluates a function on every element of a vector or matrix. Map(x^2,x,[1,2,3]) -> [1,4,9] Map(x^y,[x,y],[1,2,3],[1,2,3]) -> [1,4,27] First argument is a equation, second argument is the name or names of variables. Third and subsequent arguments are vectors or matrices, they must have the same dimensions and the number of subsequent arguments must match the number of variables specified in the second argument.

Author:
Rich Morris Created on 14-Feb-2005

Field Summary
 
Fields inherited from class org.nfunk.jep.function.PostfixMathCommand
curNumberOfParameters, numberOfParameters
 
Constructor Summary
VMap()
           
 
Method Summary
 Dimensions calcDim(Dimensions[] dims)
          Find the dimensions of this operator when applied to arguments with given dimensions.
 MatrixValueI calcValue(MatrixValueI res, MatrixValueI[] inputs)
          Calculates the value of this operator for given input with results stored in res.
 boolean checkNumberOfParameters(int n)
          Checks the number of parameters of the function.
 java.lang.Object evaluate(Node node, EvaluatorI pv)
          Performs some special evaluation on the node.
static Variable[] getVars(Node varsNode)
           
 
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

VMap

public VMap()
Method Detail

calcDim

public Dimensions calcDim(Dimensions[] dims)
                   throws ParseException
Description copied from interface: NaryOperatorI
Find the dimensions of this operator when applied to arguments with given dimensions.

Specified by:
calcDim in interface NaryOperatorI
Throws:
ParseException

calcValue

public MatrixValueI calcValue(MatrixValueI res,
                              MatrixValueI[] inputs)
                       throws ParseException
Description copied from interface: NaryOperatorI
Calculates the value of this operator for given input with results stored in res. res is returned.

Specified by:
calcValue in interface NaryOperatorI
Throws:
ParseException

getVars

public static Variable[] getVars(Node varsNode)
                          throws ParseException
Throws:
ParseException

checkNumberOfParameters

public boolean checkNumberOfParameters(int n)
Description copied from class: PostfixMathCommand
Checks the number of parameters of the function. Functions which set numberOfParameter=-1 should overload this method

Specified by:
checkNumberOfParameters in interface PostfixMathCommandI
Overrides:
checkNumberOfParameters in class PostfixMathCommand
Parameters:
n - number of parameters function will be called with.
Returns:
False if an illegal number of parameters is supplied, true otherwise.

evaluate

public java.lang.Object evaluate(Node node,
                                 EvaluatorI pv)
                          throws ParseException
Description copied from interface: CallbackEvaluationI
Performs some special evaluation on the node. This method has the responsibility for evaluating the children of the node and it should generally call
 pv.eval(node.jjtGetChild(i))   
 
for each child. The SymbolTable is not passed as an argument. This is because it is better practice to get and set variable values by using node.getVar().setValue() rather that through the SymbolTable with requires a hashtable lookup.

Specified by:
evaluate in interface CallbackEvaluationI
Parameters:
node - The current node
pv - The visitor, can be used evaluate the children
Returns:
the value after evaluation
Throws:
ParseException


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