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 Function
s are
not copied.
Built expressions are simplified by default
- Since:
- 0.8-riddler
- Author:
- Federico Vera <[email protected]>
- See Also:
-
Constructor Summary
ConstructorDescriptionFunctionExpresion
(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 TypeMethodDescriptiondouble
apply
(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
- Ifnargs
is 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
- Ifnargs
is 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
- Ifnargs
is bigger than26
-
-
Method Details
-
apply
public double apply(double... args) Description copied from class:Function
Method that does the actual calculation of the function value given the arguments
-