Package com.singularsys.jep.reals
Class RealEvaluator
- java.lang.Object
-
- com.singularsys.jep.reals.RealEvaluator
-
- All Implemented Interfaces:
Evaluator
,JepComponent
,java.io.Serializable
public class RealEvaluator extends java.lang.Object implements Evaluator
Performs fast evaluation of expressions by using primitive types double and boolean instead of objects.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RealEvaluator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
eval(Node node)
Evaluates a sub expression.java.lang.Object
evaluate(Node node)
Main entry point, evaluates a node and returns and object with the value of the node.protected static double
fromObject(java.lang.Object o)
JepComponent
getLightWeightInstance()
Gets a light-weight instance suitable for using in multiple threads.void
init(Jep jep)
Initialize the component.protected double
visit(Node node)
protected double[]
visitChildren(ASTFunNode node)
protected double
visitConstant(ASTConstant node)
protected double
visitFunction(ASTFunNode node)
protected double
visitVariable(ASTVarNode node)
-
-
-
Method Detail
-
evaluate
public java.lang.Object evaluate(Node node) throws EvaluationException
Description copied from interface:Evaluator
Main entry point, evaluates a node and returns and object with the value of the node.- Specified by:
evaluate
in interfaceEvaluator
- Parameters:
node
- node to evaluate- Returns:
- value after evaluation
- Throws:
EvaluationException
- if errors occur during evaluation;
-
eval
public java.lang.Object eval(Node node) throws EvaluationException
Description copied from interface:Evaluator
Evaluates a sub expression. This method can be called by PostfixMathCommands which implementCallbackEvaluationI
- Specified by:
eval
in interfaceEvaluator
- Parameters:
node
- node to evaluate- Returns:
- The value after evaluating the sub expression.
- Throws:
EvaluationException
- if errors occur during evaluation;
-
init
public void init(Jep jep)
Description copied from interface:JepComponent
Initialize the component. This methods is called whenever a component is added to Jep. Hence it allows components to keep track of the other components they may rely on.- Specified by:
init
in interfaceJepComponent
- Parameters:
jep
- the current Jep instance
-
visit
protected double visit(Node node) throws EvaluationException
- Throws:
EvaluationException
-
visitChildren
protected double[] visitChildren(ASTFunNode node) throws EvaluationException
- Throws:
EvaluationException
-
visitFunction
protected double visitFunction(ASTFunNode node) throws EvaluationException
- Throws:
EvaluationException
-
visitVariable
protected double visitVariable(ASTVarNode node) throws EvaluationException
- Throws:
EvaluationException
-
visitConstant
protected double visitConstant(ASTConstant node) throws EvaluationException
- Throws:
EvaluationException
-
fromObject
protected static double fromObject(java.lang.Object o) throws EvaluationException
- Throws:
EvaluationException
-
getLightWeightInstance
public JepComponent getLightWeightInstance()
Description copied from interface:JepComponent
Gets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstance
in interfaceJepComponent
- Returns:
- either an new instance, null or 'this'.
-
-