Package io.jenetics.prog.op
Enum MathOp
- java.lang.Object
-
- java.lang.Enum<MathOp>
-
- io.jenetics.prog.op.MathOp
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ABS
Return the absolute value of a double value.ACOS
Returns the arc cosine of a double value.ADD
Returns the sum of its arguments.ASIN
Returns the arc sine of a double value.ATAN
Returns the arc tangent of a value.CBRT
Returns the cube root of a double value.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.COS
Returns the trigonometric cosine of an angle.COSH
Returns the hyperbolic cosine of a double value.DIV
Returns the quotient of its arguments.EXP
Returns Euler's number e raised to the power of a double value.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.GT
Returns +1.0 if its first argument is greater than its second argument and returns -1.0 otherwise.HYPOT
Returns sqrt(x2 +y2) without intermediate overflow or underflow.LOG
Returns the natural logarithm (base e) of a double value.LOG10
Returns the base 10 logarithm of a double value.MAX
Return the maximum of two values This operation has arity 2.MIN
Return the minimum of two values.MOD
Returns the modulo of its arguments.MUL
Returns the product of its arguments.NEG
Return the negation value of a double value.POW
Returns the value of the first argument raised to the power of the second argument.RINT
Returns the double value that is closest in value to the argument and is equal to a mathematical integer.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.SIN
Returns the trigonometric sine of an angle.SINH
Returns the hyperbolic sine of a double value.SQR
Returns the square value of a given double value.SQRT
Returns the correctly rounded positive square root of a double value.SUB
Return the diff of its arguments.TAN
Returns the trigonometric tangent of an angle.TANH
Returns the hyperbolic tangent of a double value.
-
Field Summary
Fields Modifier and Type Field Description static Const<Double>
E
The double value that is closer than any other to e, the base of the natural logarithms.static 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Double
apply(Double[] args)
int
arity()
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.String
toString()
static MathOp
valueOf(String name)
Returns the enum constant of this type with the specified name.static MathOp[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
-
Methods inherited from interface io.jenetics.prog.op.Op
get, isTerminal, name
-
-
-
-
Enum Constant Detail
-
ABS
public static final MathOp ABS
Return the absolute value of a double value. This operation has arity 1.- See Also:
Math.abs(double)
-
NEG
public static final MathOp NEG
Return the negation value of a double value. This operation has arity 1.
-
MIN
public static final MathOp MIN
Return the minimum of two values. This operation has arity 2.- See Also:
Math.min(double, double)
-
MAX
public static final MathOp MAX
Return the maximum of two values This operation has arity 2.- See Also:
Math.max(double, double)
-
CEIL
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:
Math.ceil(double)
-
FLOOR
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:
Math.floor(double)
-
SIGNUM
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:
Math.signum(double)
-
RINT
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:
Math.rint(double)
-
MUL
public static final MathOp MUL
Returns the product of its arguments. This operation has arity 2.
-
DIV
public static final MathOp DIV
Returns the quotient of its arguments. This operation has arity 2.
-
POW
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:
Math.pow(double, double)
-
SQR
public static final MathOp SQR
Returns the square value of a given double value. This operation has arity 1.
-
SQRT
public static final MathOp SQRT
Returns the correctly rounded positive square root of a double value. This operation has arity 1.- See Also:
Math.sqrt(double)
-
CBRT
public static final MathOp CBRT
Returns the cube root of a double value. This operation has arity 1.- See Also:
Math.cbrt(double)
-
HYPOT
public static final MathOp HYPOT
Returns sqrt(x2 +y2) without intermediate overflow or underflow. This operation has arity 2.- See Also:
Math.hypot(double, double)
-
EXP
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:
Math.exp(double)
-
LOG
public static final MathOp LOG
Returns the natural logarithm (base e) of a double value. This operation has arity 1.- See Also:
Math.log(double)
-
LOG10
public static final MathOp LOG10
Returns the base 10 logarithm of a double value. This operation has arity 1.- See Also:
Math.log10(double)
-
SIN
public static final MathOp SIN
Returns the trigonometric sine of an angle. This operation has arity 1.- See Also:
Math.sin(double)
-
COS
public static final MathOp COS
Returns the trigonometric cosine of an angle. This operation has arity 1.- See Also:
Math.cos(double)
-
TAN
public static final MathOp TAN
Returns the trigonometric tangent of an angle. This operation has arity 1.- See Also:
Math.tan(double)
-
ACOS
public static final MathOp ACOS
Returns the arc cosine of a double value. This operation has arity 1.- See Also:
Math.acos(double)
-
ASIN
public static final MathOp ASIN
Returns the arc sine of a double value. This operation has arity 1.- See Also:
Math.asin(double)
-
ATAN
public static final MathOp ATAN
Returns the arc tangent of a value. This operation has arity 1.- See Also:
Math.atan(double)
-
COSH
public static final MathOp COSH
Returns the hyperbolic cosine of a double value. This operation has arity 1.- See Also:
Math.cosh(double)
-
SINH
public static final MathOp SINH
Returns the hyperbolic sine of a double value. This operation has arity 1.- See Also:
Math.sinh(double)
-
TANH
public static final MathOp TANH
Returns the hyperbolic tangent of a double value. This operation has arity 1.- See Also:
Math.tanh(double)
-
-
Method Detail
-
values
public static MathOp[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (MathOp c : MathOp.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static MathOp valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException
- if the argument is null
-
arity
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.
-
eval
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:
apply(Double[])
-
toMathOp
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 givenvalue
doesn't represent a mathematical expressionNullPointerException
- if the given stringvalue
isnull
- Since:
- 5.0
- See Also:
Var.reindex(TreeNode)
,Program.eval(Tree, Object[])
-
-