org.lsmp.djep.vectorJep.function
Class GenMat
java.lang.Object
org.nfunk.jep.function.PostfixMathCommand
org.lsmp.djep.vectorJep.function.GenMat
- All Implemented Interfaces:
- CallbackEvaluationI, PostfixMathCommandI
public class GenMat
- extends PostfixMathCommand
- implements CallbackEvaluationI
Generate vectors and matrices.
First argument gives the size of the vector or matrix
second argument is the function to use to generate elements of vector or matrix.
Third argument (if present gives free variables used in the function, these will
run from 1 to number of rows or columns).
For example
GenMat(3,1) -> [1,1,1]
GenMat(3,ii,ii) -> [1,2,3]
GenMat(3,rand()) -> [0.343,0.974,0.567]
GenMat([2,2],ii+jj,[ii,jj]) -> [[2,3],[3,4]]
Note the free variables should not be the same name as variables already
in use, in particular i is often set to be the complex root of unity, and should be avoided.
- Author:
- Rich Morris
Created on 14-Feb-2005
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GenMat
public GenMat()
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 nodepv
- The visitor, can be used evaluate the children
- Returns:
- the value after evaluation
- Throws:
ParseException
http://www.singularsys.com/jep Copyright © 2007 Singular Systems