Class FunctionExpresion

  • All Implemented Interfaces:
    java.io.Serializable

    public class FunctionExpresion
    extends Function
    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
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      FunctionExpresion​(java.lang.String name, int nargs, boolean det, java.lang.String expr, Function[] functions, Operator[] operators)
      Constructor.
      FunctionExpresion​(java.lang.String name, int nargs, java.lang.String expr)
      Constructor of a deterministic Expression based Function.
      FunctionExpresion​(java.lang.String name, int nargs, java.lang.String expr, Function[] functions)
      Constructor of a deterministic Expression based Function.
    • Constructor Detail

      • FunctionExpresion

        public FunctionExpresion​(java.lang.String name,
                                 int nargs,
                                 java.lang.String expr)
        Constructor of a deterministic Expression based Function.

        The arguments will be called 'a', 'b', 'c', 'd', ..., 'z'

        Parameters:
        name - Name of the function
        nargs - Number of arguments
        expr - Expression to evaluate
        Throws:
        java.lang.IllegalArgumentException - If nargs is bigger than 26
      • FunctionExpresion

        public FunctionExpresion​(java.lang.String name,
                                 int nargs,
                                 java.lang.String expr,
                                 Function[] functions)
        Constructor of a deterministic Expression based Function.

        The arguments will be called 'a', 'b', 'c', 'd', ..., 'z'

        Parameters:
        name - Name of the function
        nargs - Number of arguments
        expr - Expression to evaluate
        functions - Additional functions needed to compile this expression
        Throws:
        java.lang.IllegalArgumentException - If nargs is bigger than 26
      • FunctionExpresion

        public FunctionExpresion​(java.lang.String name,
                                 int nargs,
                                 boolean det,
                                 java.lang.String expr,
                                 Function[] functions,
                                 Operator[] operators)
        Constructor.

        The arguments will be called 'a', 'b', 'c', 'd', ..., 'z'

        Parameters:
        name - Name of the function
        nargs - Number of arguments
        det - Tells if the function is deterministic or not
        expr - Expression to evaluate
        operators - Additional operators needed to compile this expression
        functions - Additional functions needed to compile this expression
        Throws:
        java.lang.IllegalArgumentException - If nargs is bigger than 26
    • Method Detail

      • apply

        public double apply​(double... args)
        Description copied from class: Function
        Method that does the actual calculation of the function value given the arguments
        Specified by:
        apply in class Function
        Parameters:
        args - the set of arguments used for calculating the function
        Returns:
        the result of the function evaluation