public enum MathOp extends Enum<MathOp> implements Op<Double>
Math
Enum Constant and 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.
|
Modifier and Type | Field and 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.
|
Modifier and Type | Method and 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.
|
public static final MathOp ABS
Math.abs(double)
public static final MathOp NEG
public static final MathOp MIN
Math.min(double, double)
public static final MathOp MAX
Math.max(double, double)
public static final MathOp CEIL
Math.ceil(double)
public static final MathOp FLOOR
Math.floor(double)
public static final MathOp SIGNUM
Math.signum(double)
public static final MathOp RINT
Math.rint(double)
public static final MathOp MUL
public static final MathOp DIV
public static final MathOp POW
Math.pow(double, double)
public static final MathOp SQR
public static final MathOp SQRT
Math.sqrt(double)
public static final MathOp CBRT
Math.cbrt(double)
public static final MathOp HYPOT
Math.hypot(double, double)
public static final MathOp EXP
Math.exp(double)
public static final MathOp LOG
Math.log(double)
public static final MathOp LOG10
Math.log10(double)
public static final MathOp SIN
Math.sin(double)
public static final MathOp COS
Math.cos(double)
public static final MathOp TAN
Math.tan(double)
public static final MathOp ACOS
Math.acos(double)
public static final MathOp ASIN
Math.asin(double)
public static final MathOp ATAN
Math.atan(double)
public static final MathOp COSH
Math.cosh(double)
public static final MathOp SINH
Math.sinh(double)
public static final MathOp TANH
Math.tanh(double)
public static final Const<Double> PI
Math.PI
public static MathOp[] values()
for (MathOp c : MathOp.values()) System.out.println(c);
public static MathOp valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic int arity()
Op
public double eval(double... args)
args
- the operation argumentsapply(Double[])
public static Op<Double> toMathOp(String string)
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;
string
- the string representation of an operation which should be
convertedIllegalArgumentException
- if the given value
doesn't
represent a mathematical expressionNullPointerException
- if the given string value
is
null
Var.reindex(TreeNode)
,
Program.eval(Tree, Object[])
© 2007-2019 Franz Wilhelmstötter (2019-11-18 20:30)