Package org.lsmp.djep.vectorJep.function
Class VEle
java.lang.Object
org.nfunk.jep.function.PostfixMathCommand
org.lsmp.djep.vectorJep.function.VEle
- All Implemented Interfaces:
BinaryOperatorI
,PostfixMathCommandI
- Direct Known Subclasses:
ArrayAccess
ele(x,i) returns the i-th element of a vector x.
ele(m,[i,j]) returns the (i-th,j-th) element of a matrix m.
Note this follows the mathematical indexing convention with indices starting from 1
rather than the computer science convention with indices starting from 0.
Hence
a = [1,2,3,4];
ele(a,1); // returns 1
m = [[1,2],[3,4]];
ele(m,[2,2]); // return 4
New parser feature allow a[] notation to be used.
a=[1,2,3,4];
a[3]; // returns 3
b=[[1,2],[3,4]];
b[1,2]; // returns 2
- Author:
- Rich Morris Created on 15-Nov-2003
-
Field Summary
Fields inherited from class org.nfunk.jep.function.PostfixMathCommand
curNumberOfParameters, numberOfParameters
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncalcDim
(Dimensions ldim, Dimensions rdim) Find the dimensions of this operator when applied to arguments with given dimensions.calcValue
(MatrixValueI res, MatrixValueI param1, MatrixValueI param2) Calculates the value of this operator for given input with results stored in res.void
Throws an exception because this method should never be called under normal circumstances.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
Methods inherited from interface org.nfunk.jep.function.PostfixMathCommandI
checkNumberOfParameters, getNumberOfParameters, setCurNumberOfParameters
-
Constructor Details
-
VEle
public VEle()
-
-
Method Details
-
calcDim
Description copied from interface:BinaryOperatorI
Find the dimensions of this operator when applied to arguments with given dimensions.- Specified by:
calcDim
in interfaceBinaryOperatorI
- Throws:
ParseException
-
calcValue
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI param1, MatrixValueI param2) throws ParseException Description copied from interface:BinaryOperatorI
Calculates the value of this operator for given input with results stored in res. res is returned. Using this method is slightly faster than the standard run method as it eliminates the construction of tempoary objects.- Specified by:
calcValue
in interfaceBinaryOperatorI
- Throws:
ParseException
-
run
Description copied from class:PostfixMathCommand
Throws an exception because this method should never be called under normal circumstances. Each function should use it's own run() method for evaluating the function. This includes popping off the parameters from the stack, and pushing the result back on the stack.- Specified by:
run
in interfacePostfixMathCommandI
- Overrides:
run
in classPostfixMathCommand
- Throws:
ParseException
-