Enum Class MathOp
- All Implemented Interfaces:
Op<Double>, Serializable, Comparable<MathOp>, Constable, Function<Double[],Double>, Supplier<Op<Double>>
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionReturn 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
FieldsModifier and TypeFieldDescriptionThe double value that is closer than any other to e, the base of the natural logarithms.The names of all defined operation names.The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter. -
Method Summary
Modifier and TypeMethodDescriptionintarity()Return the arity of the operation function.doubleeval(double... args) Evaluates the operation with the given arguments.Converts the string representation of an operation to the operation object.toString()static MathOpReturns the enum constant of this class with the specified name.static MathOp[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOfMethods inherited from interface Op
get, isTerminal, name
-
Enum Constant Details
-
ABS
-
NEG
-
ID
-
MIN
-
MAX
-
CEIL
-
FLOOR
-
SIGNUM
-
RINT
-
ADD
-
SUB
-
MUL
-
DIV
-
MOD
-
POW
-
SQR
-
SQRT
-
CBRT
-
HYPOT
-
EXP
-
LOG
-
LOG10
-
SIN
-
COS
-
TAN
-
ACOS
-
ASIN
-
ATAN
-
COSH
-
SINH
-
TANH
-
GT
-
-
Field Details
-
PI
-
E
-
NAMES
-
-
Method Details
-
values
-
valueOf
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 nameNullPointerException- if the argument is null
-
arity
-
apply
-
eval
Evaluates the operation with the given arguments.- Parameters:
args- the operation arguments- Returns:
- the evaluated operation
- Since:
- 5.0
- See Also:
-
toString
-
toMathOp
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 givenvaluedoesn't represent a mathematical expressionNullPointerException- if the given stringvalueisnull- Since:
- 5.0
- See Also:
-