Package net.objecthunter.exp4j.extras
Class FunctionExpresion
java.lang.Object
net.objecthunter.exp4j.function.Function
net.objecthunter.exp4j.extras.FunctionExpresion
- All Implemented Interfaces:
Serializable
This class contains a wrapper that allows creating expression based functions.
Note: This class might will fail in
threaded evaluations, if you need to use this to evaluate operations
concurrently, please create a new instance per thread.This is particularly
important when using Expression.copy() because Functions are
not copied.
Built expressions are simplified by default
- Since:
- 0.8-riddler
- Author:
- Federico Vera <[email protected]>
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionFunctionExpresion(String name, int nargs, boolean det, String expr, Function[] functions, Operator[] operators) Constructor.FunctionExpresion(String name, int nargs, String expr) Constructor of a deterministic Expression based Function.FunctionExpresion(String name, int nargs, String expr, Function[] functions) Constructor of a deterministic Expression based Function. -
Method Summary
Modifier and TypeMethodDescriptiondoubleapply(double... args) Method that does the actual calculation of the function value given the argumentsMethods inherited from class net.objecthunter.exp4j.function.Function
getName, getNumArguments, isDeterministic, isValidFunctionName
-
Constructor Details
-
FunctionExpresion
Constructor of a deterministic Expression based Function.The arguments will be called
'a','b','c','d', ...,'z'- Parameters:
name- Name of the functionnargs- Number of argumentsexpr- Expression to evaluate- Throws:
IllegalArgumentException- Ifnargsis bigger than26
-
FunctionExpresion
Constructor of a deterministic Expression based Function.The arguments will be called
'a','b','c','d', ...,'z'- Parameters:
name- Name of the functionnargs- Number of argumentsexpr- Expression to evaluatefunctions- Additional functions needed to compile this expression- Throws:
IllegalArgumentException- Ifnargsis bigger than26
-
FunctionExpresion
public FunctionExpresion(String name, int nargs, boolean det, String expr, Function[] functions, Operator[] operators) Constructor.The arguments will be called
'a','b','c','d', ...,'z'- Parameters:
name- Name of the functionnargs- Number of argumentsdet- Tells if the function is deterministic or notexpr- Expression to evaluateoperators- Additional operators needed to compile this expressionfunctions- Additional functions needed to compile this expression- Throws:
IllegalArgumentException- Ifnargsis bigger than26
-
-
Method Details
-
apply
public double apply(double... args) Description copied from class:FunctionMethod that does the actual calculation of the function value given the arguments
-