public class Ele extends NaryFunction implements LValueI
a=[4,3,2,1];
a[2]; // Returns 2
a[2]=5; // Sets the 2nd element of a to 5. So a is now [4,5,2,1]
// Two dimensional matrices only work with the configurable parser
b=[[1,2,3],[4,5,6]];
b[2][3]; // returns 6
b[2][3]=7; // sets 3rd element of 2nd row to 7
Modifier and Type | Field and Description |
---|---|
protected int |
indexShift |
curNumberOfParameters, name, NaN, numberOfParameters
Constructor and Description |
---|
Ele()
Element access with mathematical convention, first element has index 1
|
Ele(boolean javaIndex)
Element access, either java convention (first element has index 0) or mathematical convention (first element has index 1) can be specified.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkNumberOfParameters(int n)
Checks the number of parameters of the function.
|
java.lang.Object |
ele(java.lang.Object[] args)
Find the element of an array.
|
java.lang.Object |
ele(java.lang.Object vec,
java.lang.Object indexObject)
Find the element of a vector
|
java.lang.Object |
ele(java.lang.Object mat,
java.lang.Object[] args)
Find element of a multi-dimensional array
|
java.lang.Object |
ele(java.lang.Object mat,
java.lang.Object row,
java.lang.Object col)
Find the element of a matrix
|
java.lang.Object |
eval(java.lang.Object[] args)
Evaluate the function
|
protected Variable |
getVariable(Evaluator pv,
ASTVarNode node)
Find the variable associated with a node.
|
void |
set(Evaluator pv,
Node node,
java.lang.Object value)
Performs appropriate action to set an LValue.
|
run
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
public Ele()
public Ele(boolean javaIndex)
javaIndex
- whether to use the java convention, if true index start at 0.public boolean checkNumberOfParameters(int n)
PostfixMathCommand
checkNumberOfParameters
in interface PostfixMathCommandI
checkNumberOfParameters
in class PostfixMathCommand
n
- number of parameters function will be called with.public void set(Evaluator pv, Node node, java.lang.Object value) throws EvaluationException
LValueI
set
in interface LValueI
pv
- a pointer to the evaluator. The pv.eval() method can be used to evaluate the children of the node.node
- The top node for the LValuevalue
- the value obtained by evaluating the right hand side.EvaluationException
- if the calculation cannot be performedpublic java.lang.Object eval(java.lang.Object[] args) throws EvaluationException
NaryFunction
eval
in class NaryFunction
args
- arguments to the functionEvaluationException
- if the calculation cannot be performedpublic java.lang.Object ele(java.lang.Object[] args) throws EvaluationException
ele(Object, Object)
, ele(Object, Object, Object)
or ele(Object, Object[])
depending on number of arguments.args
- First element is the vector or matrix, subsequent elements are indicesEvaluationException
- if the calculation cannot be performedpublic java.lang.Object ele(java.lang.Object vec, java.lang.Object indexObject) throws EvaluationException
vec
- the vectorindexObject
- the index either as a vector with a single value or as a single value.EvaluationException
- if the calculation cannot be performedpublic java.lang.Object ele(java.lang.Object mat, java.lang.Object row, java.lang.Object col) throws EvaluationException
mat
- the matrix represented a a Vector<Vector<Object>>row
- the indexcol
- the indexEvaluationException
- if the calculation cannot be performedpublic java.lang.Object ele(java.lang.Object mat, java.lang.Object[] args) throws EvaluationException
mat
- the arrayargs
- array of indicesEvaluationException
- if the calculation cannot be performedprotected Variable getVariable(Evaluator pv, ASTVarNode node)
pv
- the evaluatornode
- the nodeCopyright © 2018 Singular Systems http://www.singularsys.com/jep