vec_math
Class ExpressionMultidimensional

java.lang.Object
  extended by vec_math.Node<String>
      extended by vec_math.StringNode
          extended by vec_math.ExpressionNode
              extended by vec_math.ExpressionMultidimensional
All Implemented Interfaces:
Serializable, Multidimensional

public class ExpressionMultidimensional
extends ExpressionNode
implements Multidimensional

A representation of a Multidimensional function using a parsable expression. The expression must be of the following format:

   sin($0)+cos($1)+$3-exp($2),
   
where evaluation is done by replacing the variables $n with the arguments of the VectorG supplied.

See Also:
Serialized Form

Nested Class Summary
static class ExpressionMultidimensional.Test
          Test by evaluating an arbitrary function at the provided position.
 
Field Summary
private  Map<String,Integer> lookup
          The lookup table linking variable names to vector indices.
 
Constructor Summary
ExpressionMultidimensional(String node, int dimension)
          Constructs a new expression using a specified string.
ExpressionMultidimensional(String node, Map<String,Integer> varna)
          Constructs a new expression using a specified string and a specific variable name lookup table.
ExpressionMultidimensional(StringNode par, String root, int level)
          Constructs a daugther node.
 
Method Summary
 int dimension()
          The number of variables define the number of dimensions, if we have not set a dimension from the outside.
 double evaluate(VectorG x)
          The expression is checked for the occurence of the variable.
 
Methods inherited from class vec_math.ExpressionNode
getValue, isVariable
 
Methods inherited from class vec_math.StringNode
getVariables, parseOperator, parseSub, replaceVariable, replaceVariable, setValidOperator
 
Methods inherited from class vec_math.Node
equals, getLevel, getParent, getParseSource, getSub, getSubAt, getSubNodeNumber, getTie, isFinal, isParsed, isRoot, parse, parse, setParse, setParseSource, setSub, setTie, setValue, toString, traceVariable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lookup

private Map<String,Integer> lookup
The lookup table linking variable names to vector indices. Size is dimension of this multidimensional function.

Constructor Detail

ExpressionMultidimensional

public ExpressionMultidimensional(String node,
                                  int dimension)
Constructs a new expression using a specified string. The dimension is specified and the variable names default to '$n', where n is the index in the vector at evaluate(vec_math.VectorG)


ExpressionMultidimensional

public ExpressionMultidimensional(String node,
                                  Map<String,Integer> varna)
Constructs a new expression using a specified string and a specific variable name lookup table. This varname table must link name as found in the expression to Integers. The Integer is the index in the evaluate(vec_math.VectorG) vector argument.


ExpressionMultidimensional

public ExpressionMultidimensional(StringNode par,
                                  String root,
                                  int level)
Constructs a daugther node. This constructor is called repeatedly during parsing and must be present.

Method Detail

dimension

public int dimension()
The number of variables define the number of dimensions, if we have not set a dimension from the outside. If construction was successful, we know that everything is o.k.

Specified by:
dimension in interface Multidimensional

evaluate

public double evaluate(VectorG x)
The expression is checked for the occurence of the variable. They are replaced with the value supplied and the evaluated number is returned.

Specified by:
evaluate in interface Multidimensional