Enum Class MathOp

java.lang.Object
java.lang.Enum<MathOp>
io.jenetics.prog.op.MathOp
All Implemented Interfaces:
Op<Double>, Serializable, Comparable<MathOp>, Constable, Function<Double[],Double>, Supplier<Op<Double>>

public enum MathOp extends Enum<MathOp> implements Op<Double>
This class contains operations for performing basic numeric operations.
Since:
3.9
Version:
5.0
See Also:
  • Nested Class Summary Link icon

    Nested classes/interfaces inherited from class java.lang.Enum Link icon

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary Link icon

    Enum Constants
    Enum Constant
    Description
    Return the absolute value of a double value.
    Returns the arc cosine of a double value.
    Returns the sum of its arguments.
    Returns the arc sine of a double value.
    Returns the arc tangent of a value.
    Returns the cube root of a double value.
    Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.
    Returns the trigonometric cosine of an angle.
    Returns the hyperbolic cosine of a double value.
    Returns the quotient of its arguments.
    Returns Euler's number e raised to the power of a double value.
    Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.
    Returns +1.0 if its first argument is greater than its second argument and returns -1.0 otherwise.
    Returns sqrt(x2 +y2) without intermediate overflow or underflow.
    The identity function.
    Returns the natural logarithm (base e) of a double value.
    Returns the base 10 logarithm of a double value.
    Return the maximum of two values This operation has arity 2.
    Return the minimum of two values.
    Returns the modulo of its arguments.
    Returns the product of its arguments.
    Return the negation value of a double value.
    Returns the value of the first argument raised to the power of the second argument.
    Returns the double value that is closest in value to the argument and is equal to a mathematical integer.
    Returns the signum function of the argument; zero if the argument is zero, 1.0 if the argument is greater than zero, -1.0 if the argument is less than zero.
    Returns the trigonometric sine of an angle.
    Returns the hyperbolic sine of a double value.
    Returns the square value of a given double value.
    Returns the correctly rounded positive square root of a double value.
    Return the diff of its arguments.
    Returns the trigonometric tangent of an angle.
    Returns the hyperbolic tangent of a double value.
  • Field Summary Link icon

    Fields
    Modifier and Type
    Field
    Description
    static final Const<Double>
    The double value that is closer than any other to e, the base of the natural logarithms.
    static final Set<String>
    The names of all defined operation names.
    static final Const<Double>
    The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    apply(Double[] args)
     
    int
    Return the arity of the operation function.
    double
    eval(double... args)
    Evaluates the operation with the given arguments.
    static Op<Double>
    toMathOp(String string)
    Converts the string representation of an operation to the operation object.
     
    static MathOp
    Returns the enum constant of this class with the specified name.
    static MathOp[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object Link icon

    getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.function.Function Link icon

    andThen, compose

    Methods inherited from interface io.jenetics.prog.op.Op Link icon

    get, isTerminal, name
  • Enum Constant Details Link icon

    • ABS Link icon

      public static final MathOp ABS
      Return the absolute value of a double value. This operation has arity 1.
      See Also:
    • NEG Link icon

      public static final MathOp NEG
      Return the negation value of a double value. This operation has arity 1.
    • ID Link icon

      public static final MathOp ID
      The identity function.
    • MIN Link icon

      public static final MathOp MIN
      Return the minimum of two values. This operation has arity 2.
      See Also:
    • MAX Link icon

      public static final MathOp MAX
      Return the maximum of two values This operation has arity 2.
      See Also:
    • CEIL Link icon

      public static final MathOp CEIL
      Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer. This operation has arity 1.
      See Also:
    • FLOOR Link icon

      public static final MathOp FLOOR
      Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer. This operation has arity 1.
      See Also:
    • SIGNUM Link icon

      public static final MathOp SIGNUM
      Returns the signum function of the argument; zero if the argument is zero, 1.0 if the argument is greater than zero, -1.0 if the argument is less than zero. This operation has arity 1.
      See Also:
    • RINT Link icon

      public static final MathOp RINT
      Returns the double value that is closest in value to the argument and is equal to a mathematical integer. This operation has arity 1.
      See Also:
    • ADD Link icon

      public static final MathOp ADD
      Returns the sum of its arguments. This operation has arity 2.
    • SUB Link icon

      public static final MathOp SUB
      Return the diff of its arguments. This operation has arity 2.
    • MUL Link icon

      public static final MathOp MUL
      Returns the product of its arguments. This operation has arity 2.
    • DIV Link icon

      public static final MathOp DIV
      Returns the quotient of its arguments. This operation has arity 2.
    • MOD Link icon

      public static final MathOp MOD
      Returns the modulo of its arguments. This operation has arity 2.
    • POW Link icon

      public static final MathOp POW
      Returns the value of the first argument raised to the power of the second argument. This operation has arity 2.
      See Also:
    • SQR Link icon

      public static final MathOp SQR
      Returns the square value of a given double value. This operation has arity 1.
    • SQRT Link icon

      public static final MathOp SQRT
      Returns the correctly rounded positive square root of a double value. This operation has arity 1.
      See Also:
    • CBRT Link icon

      public static final MathOp CBRT
      Returns the cube root of a double value. This operation has arity 1.
      See Also:
    • HYPOT Link icon

      public static final MathOp HYPOT
      Returns sqrt(x2 +y2) without intermediate overflow or underflow. This operation has arity 2.
      See Also:
    • EXP Link icon

      public static final MathOp EXP
      Returns Euler's number e raised to the power of a double value. This operation has arity 1.
      See Also:
    • LOG Link icon

      public static final MathOp LOG
      Returns the natural logarithm (base e) of a double value. This operation has arity 1.
      See Also:
    • LOG10 Link icon

      public static final MathOp LOG10
      Returns the base 10 logarithm of a double value. This operation has arity 1.
      See Also:
    • SIN Link icon

      public static final MathOp SIN
      Returns the trigonometric sine of an angle. This operation has arity 1.
      See Also:
    • COS Link icon

      public static final MathOp COS
      Returns the trigonometric cosine of an angle. This operation has arity 1.
      See Also:
    • TAN Link icon

      public static final MathOp TAN
      Returns the trigonometric tangent of an angle. This operation has arity 1.
      See Also:
    • ACOS Link icon

      public static final MathOp ACOS
      Returns the arc cosine of a double value. This operation has arity 1.
      See Also:
    • ASIN Link icon

      public static final MathOp ASIN
      Returns the arc sine of a double value. This operation has arity 1.
      See Also:
    • ATAN Link icon

      public static final MathOp ATAN
      Returns the arc tangent of a value. This operation has arity 1.
      See Also:
    • COSH Link icon

      public static final MathOp COSH
      Returns the hyperbolic cosine of a double value. This operation has arity 1.
      See Also:
    • SINH Link icon

      public static final MathOp SINH
      Returns the hyperbolic sine of a double value. This operation has arity 1.
      See Also:
    • TANH Link icon

      public static final MathOp TANH
      Returns the hyperbolic tangent of a double value. This operation has arity 1.
      See Also:
    • GT Link icon

      public static final MathOp GT
      Returns +1.0 if its first argument is greater than its second argument and returns -1.0 otherwise.
      Since:
      5.0
  • Field Details Link icon

    • PI Link icon

      public static final Const<Double> PI
      The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter. This is a terminal operation.
      See Also:
    • E Link icon

      public static final Const<Double> E
      The double value that is closer than any other to e, the base of the natural logarithms. This is a terminal operation.
      See Also:
    • NAMES Link icon

      public static final Set<String> NAMES
      The names of all defined operation names.
      Since:
      7.0
  • Method Details Link icon

    • values Link icon

      public static MathOp[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf Link icon

      public static MathOp valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • arity Link icon

      public int arity()
      Description copied from interface: Op
      Return the arity of the operation function. If the arity is zero, the operation is terminal operation.
      Specified by:
      arity in interface Op<Double>
      Returns:
      the arity of the operation
    • apply Link icon

      public Double apply(Double[] args)
      Specified by:
      apply in interface Function<Double[],Double>
    • eval Link icon

      public double eval(double... args)
      Evaluates the operation with the given arguments.
      Parameters:
      args - the operation arguments
      Returns:
      the evaluated operation
      Since:
      5.0
      See Also:
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Enum<MathOp>
    • toMathOp Link icon

      public static Op<Double> toMathOp(String string)
      Converts the string representation of an operation to the operation object. It is used for converting the string representation of a tree to an operation tree. If you use it that way, you should not forget to re-index the tree variables.
      final TreeNode<Op<Double>> tree = TreeNode.parse(
          "add(mul(x,y),sub(y,x))",
          MathOp::toMathOp
      );
      
      assert Program.eval(tree, 10.0, 5.0) == 100.0;
      Var.reindex(tree);
      assert Program.eval(tree, 10.0, 5.0) == 45.0;
      
      Parameters:
      string - the string representation of an operation which should be converted
      Returns:
      the operation, converted from the given string
      Throws:
      IllegalArgumentException - if the given value doesn't represent a mathematical expression
      NullPointerException - if the given string value is null
      Since:
      5.0
      See Also: