Class MathFunctions
- java.lang.Object
-
- org.vedantatree.expressionoasis.extensions.MathFunctions
-
public class MathFunctions extends Object
This class provides the math function for experssion evaluator
-
-
Constructor Summary
Constructors Constructor Description MathFunctions(ExpressionContext expressionContext)
Default constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Double
abs(Double value)
Returns the absolute valuestatic Long
abs(Long value)
static Double
acos(Number value)
Returns the trigonometric arc cosine of an anglestatic Double
asin(Number value)
Returns the trigonometric arc sine of an anglestatic Double
atan(Number value)
Returns the trigonometric arc tangent of an anglestatic Double
atan2(Number y, Number x)
Converts rectangular coordinates (x
,y
) to polar (r, theta ).static Double
ceil(Number 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.static Double
cos(Number value)
Returns the trigonometric cosine of an anglestatic Double
exp(Number value)
Returns Euler's number e raised to the power of adouble
value.static Double
floor(Number 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.static Double
log(Number value)
Returns the natural logarithm (base e ) of adouble
value.static Double
max(Double value1, Double value2)
Returns the maximum of two numbers.static Double
max(Double value1, Long value2)
Returns the maximum of two numbers.static Double
max(Long value1, Double value2)
Returns the maximum of two numbers.static Long
max(Long value1, Long value2)
Returns the maximum of two numbers.static Double
min(Double value1, Double value2)
Returns the minimum of two numbers.static Long
min(Long value1, Long value2)
Returns the minimum of two numbers.static Double
pow(Number base, Number exponent)
Computes the powerstatic Double
random()
Returns adouble
value with a positive sign, greater than or equal to0.0
and less than1.0
.static Double
rint(Double value)
Returns thedouble
value that is closest in value to the argument and is equal to a mathematical integer.static Long
round(Double value)
Returns the closestint
to the argument.static Double
sin(Number value)
Returns the trigonometric sine of an anglestatic Double
sqrt(Number value)
Returns the correctly rounded positive square root of adouble
value.Double
sum(Double[] vals)
static Double
tan(Number value)
Returns the trigonometric tangent of an angle
-
-
-
Constructor Detail
-
MathFunctions
public MathFunctions(ExpressionContext expressionContext)
Default constructor
-
-
Method Detail
-
min
public static Double min(Double value1, Double value2)
Returns the minimum of two numbers.- Parameters:
value1
-value2
-- Returns:
-
min
public static Long min(Long value1, Long value2)
Returns the minimum of two numbers.- Parameters:
value1
-value2
-- Returns:
-
max
public static Double max(Double value1, Double value2)
Returns the maximum of two numbers.- Parameters:
value1
-value2
-- Returns:
-
max
public static Double max(Double value1, Long value2)
Returns the maximum of two numbers.- Parameters:
value1
-value2
-- Returns:
-
max
public static Double max(Long value1, Double value2)
Returns the maximum of two numbers.- Parameters:
value1
-value2
-- Returns:
-
max
public static Long max(Long value1, Long value2)
Returns the maximum of two numbers.- Parameters:
value1
-value2
-- Returns:
-
sin
public static Double sin(Number value)
Returns the trigonometric sine of an angle- Parameters:
value
-- Returns:
-
cos
public static Double cos(Number value)
Returns the trigonometric cosine of an angle- Parameters:
value
-- Returns:
-
tan
public static Double tan(Number value)
Returns the trigonometric tangent of an angle- Parameters:
value
-- Returns:
-
asin
public static Double asin(Number value)
Returns the trigonometric arc sine of an angle- Parameters:
value
-- Returns:
-
acos
public static Double acos(Number value)
Returns the trigonometric arc cosine of an angle- Parameters:
value
-- Returns:
-
atan
public static Double atan(Number value)
Returns the trigonometric arc tangent of an angle- Parameters:
value
-- Returns:
-
atan2
public static Double atan2(Number y, Number x)
Converts rectangular coordinates (x
,y
) to polar (r, theta ).- Parameters:
y
-x
-- Returns:
-
exp
public static Double exp(Number value)
Returns Euler's number e raised to the power of adouble
value. Special cases:- Parameters:
value
- the exponent to raise e to.- Returns:
-
pow
public static Double pow(Number base, Number exponent)
Computes the power- Parameters:
base
-exponent
-- Returns:
-
log
public static Double log(Number value)
Returns the natural logarithm (base e ) of adouble
value.- Parameters:
value
- a value- Returns:
- the value ln
a
, the natural logarithm ofa
.
-
sqrt
public static Double sqrt(Number value)
Returns the correctly rounded positive square root of adouble
value.- Parameters:
value
- a value.- Returns:
- the positive square root of
a
. If the argument is NaN or less than zero, the result is NaN.
-
ceil
public static Double ceil(Number 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.- Parameters:
a
- a value.- Returns:
-
floor
public static Double floor(Number 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.- Parameters:
value
- a value.- Returns:
-
rint
public static Double rint(Double value)
Returns thedouble
value that is closest in value to the argument and is equal to a mathematical integer. If twodouble
values that are mathematical integers are equally close, the result is the integer value that is even.- Parameters:
value
- adouble
value.- Returns:
-
round
public static Long round(Double value)
Returns the closestint
to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to typeint
. In other words, the result is equal to the value of the expression:(int) Math.floor( a + 0.5f )
- Parameters:
a
- a floating-point value to be rounded to an integer.- Returns:
- the value of the argument rounded to the nearest
int
value.
-
random
public static Double random()
Returns adouble
value with a positive sign, greater than or equal to0.0
and less than1.0
. Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range.- Returns:
- a pseudorandom
double
greater than or equal to0.0
and less than1.0
.
-
-