com.graphbuilder.math
Class FuncNode

java.lang.Object
  extended bycom.graphbuilder.math.Expression
      extended bycom.graphbuilder.math.TermNode
          extended bycom.graphbuilder.math.FuncNode

public class FuncNode
extends TermNode

A node of an expression tree that represents a function. A FuncNode can have 0 or more children.


Field Summary
 
Fields inherited from class com.graphbuilder.math.TermNode
name, negate
 
Fields inherited from class com.graphbuilder.math.Expression
parent
 
Constructor Summary
FuncNode(java.lang.String name, boolean negate)
           
 
Method Summary
 void add(Expression x)
          Adds the expression as a child.
 Expression child(int i)
          Returns the child expression at the specified index.
 double eval(VarMap v, FuncMap f)
          Evaluates each of the children, storing the result in an internal double array.
 void insert(Expression x, int i)
          Adds the expression as a child at the specified index.
 int numChildren()
          Returns the number of child expressions.
 void remove(Expression x)
          Removes the specified expression as a child.
 
Methods inherited from class com.graphbuilder.math.TermNode
getName, getNegate, setName, setNegate
 
Methods inherited from class com.graphbuilder.math.Expression
checkBeforeAccept, getFunctionNames, getParent, getVariableNames, isDescendent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FuncNode

public FuncNode(java.lang.String name,
                boolean negate)
Method Detail

add

public void add(Expression x)
Adds the expression as a child.


insert

public void insert(Expression x,
                   int i)
Adds the expression as a child at the specified index.


remove

public void remove(Expression x)
Removes the specified expression as a child. Does nothing if the expression was not a child.


numChildren

public int numChildren()
Returns the number of child expressions.


child

public Expression child(int i)
Returns the child expression at the specified index.


eval

public double eval(VarMap v,
                   FuncMap f)
Evaluates each of the children, storing the result in an internal double array. The FuncMap is used to obtain a Function object based on the name of this FuncNode. The function is passed the double array and returns a result. If negate is true, the result is negated. The result is then returned. The numParam passed to the function is the number of children of this FuncNode.

Specified by:
eval in class Expression