weka.core
Class MathematicalExpression.TreeNode

java.lang.Object
  extended by weka.core.MathematicalExpression.TreeNode
All Implemented Interfaces:
java.io.Serializable
Enclosing class:
MathematicalExpression

public static class MathematicalExpression.TreeNode
extends java.lang.Object
implements java.io.Serializable

Tree Node of MathematicalExpression

Version:
$Revision: 1.3 $
Author:
Eibe Frank (eibe@cs.waikato.ac.nz), Prados Julien (julien.prados@cui.unige.ch)
See Also:
Serialized Form

Field Summary
static int[] arity
          The arity of the known functions
static java.lang.String[] funs
          The known functions
 
Constructor Summary
MathematicalExpression.TreeNode(double v)
          Construct a constant node
MathematicalExpression.TreeNode(int t, java.util.Vector ops)
          Construct an operator node
MathematicalExpression.TreeNode(MathematicalExpression.TreeNode n)
          Construct a constant node
MathematicalExpression.TreeNode(java.lang.String v)
          Construct a variable node
MathematicalExpression.TreeNode(java.lang.String f, java.util.Vector ops)
          Construct a function node
MathematicalExpression.TreeNode(java.util.Vector p)
          Construct an ifelse node
 
Method Summary
 double eval(java.util.Map symbols)
          Evaluate the tree with for specific values of the variables
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

funs

public static java.lang.String[] funs
The known functions


arity

public static int[] arity
The arity of the known functions

Constructor Detail

MathematicalExpression.TreeNode

public MathematicalExpression.TreeNode(double v)
Construct a constant node

Parameters:
v - the value of the constant

MathematicalExpression.TreeNode

public MathematicalExpression.TreeNode(MathematicalExpression.TreeNode n)
Construct a constant node

Parameters:
n - the value of the constant

MathematicalExpression.TreeNode

public MathematicalExpression.TreeNode(java.lang.String v)
Construct a variable node

Parameters:
v - the name of the variable

MathematicalExpression.TreeNode

public MathematicalExpression.TreeNode(java.util.Vector p)
Construct an ifelse node

Parameters:
p - parameters of the ifelse

MathematicalExpression.TreeNode

public MathematicalExpression.TreeNode(java.lang.String f,
                                       java.util.Vector ops)
                                throws java.lang.Exception
Construct a function node

Parameters:
f - the name of the function
ops - the operands of the function
Throws:
java.lang.Exception - if function is unknown or wrong arity

MathematicalExpression.TreeNode

public MathematicalExpression.TreeNode(int t,
                                       java.util.Vector ops)
                                throws java.lang.Exception
Construct an operator node

Parameters:
t - the operator '+','-','*','/'
ops - the operands of the operator
Throws:
java.lang.Exception - is something goes wrong
Method Detail

eval

public double eval(java.util.Map symbols)
            throws java.lang.Exception
Evaluate the tree with for specific values of the variables

Parameters:
symbols - a map associating a Double value to each variable name
Returns:
the evaluation
Throws:
java.lang.Exception - if a symbol, function or node type is unknown