Class LambdaFunGenerator
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.extensions.lambda.LambdaFunGenerator
- All Implemented Interfaces:
CallbackEvaluationI,JepComponent,PostfixMathCommandI,Serializable
public class LambdaFunGenerator
extends PostfixMathCommand
implements CallbackEvaluationI, JepComponent
Jep Function that generates a
LambdaFunction.
The lambda definition operator such as =>
defined in LambdaOperatorTable uses this class for its implementation.
In the expression vars => expr,
the left hand argument is the argument or list of arguments, and
the right hand argument an expression, using these variable, for example:
x => x^2
[x,y] => x*y
[[x1,x2],[y1,y2]] => x1*y1+x2*y2
[u,v] => u[1]*v[1]+u[2]*v[2]
The last two expressions implement a dot product of two vectors, The first decomposes the vectors into their components, and the second uses indexing.
The names of the generated functions is specified using the
com.singularsys.extensions.lambda.LambdaFunGenerator.nameFormat
message property, and a unique instance number.
The default format is lambda1.
Since Jep 4.1, extensions 2.2 pattern matching of vectors has been implemented. Nested lambda functions are now
- See Also:
-
Field Summary
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, description, name, NaN, numberOfParameters -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionTheevaluatemethod generates aLambdaFunctionfrom a node tree.Gets a light-weight instance suitable for using in multiple threads.voidInitialize the component.Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, checkNumberOfParameters, getDescription, getDescription, getDescriptionWithType, getName, getNumberOfParameters, run, setCurNumberOfParameters, setDescription, setName, toString, toString
-
Constructor Details
-
LambdaFunGenerator
public LambdaFunGenerator()
-
-
Method Details
-
init
Description copied from interface:JepComponentInitialize the component. This method 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:
initin interfaceJepComponent- Parameters:
jep- the current Jep instance
-
evaluate
Theevaluatemethod generates aLambdaFunctionfrom a node tree.- Specified by:
evaluatein interfaceCallbackEvaluationI- Parameters:
node- the node tree of the expressionev- the evaluator- Returns:
- a
LambdaFunction. - Throws:
EvaluationException- if the calculation cannot be performed- See Also:
-
getLightWeightInstance
Description copied from interface:JepComponentGets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstancein interfaceJepComponent- Returns:
- either a new instance, null or 'this'.
-