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 Doubleabs(Double value)Returns the absolute valuestatic Longabs(Long value)static Doubleacos(Number value)Returns the trigonometric arc cosine of an anglestatic Doubleasin(Number value)Returns the trigonometric arc sine of an anglestatic Doubleatan(Number value)Returns the trigonometric arc tangent of an anglestatic Doubleatan2(Number y, Number x)Converts rectangular coordinates (x,y) to polar (r, theta ).static Doubleceil(Number value)Returns the smallest (closest to negative infinity)doublevalue that is greater than or equal to the argument and is equal to a mathematical integer.static Doublecos(Number value)Returns the trigonometric cosine of an anglestatic Doubleexp(Number value)Returns Euler's number e raised to the power of adoublevalue.static Doublefloor(Number value)Returns the largest (closest to positive infinity)doublevalue that is less than or equal to the argument and is equal to a mathematical integer.static Doublelog(Number value)Returns the natural logarithm (base e ) of adoublevalue.static Doublemax(Double value1, Double value2)Returns the maximum of two numbers.static Doublemax(Double value1, Long value2)Returns the maximum of two numbers.static Doublemax(Long value1, Double value2)Returns the maximum of two numbers.static Longmax(Long value1, Long value2)Returns the maximum of two numbers.static Doublemin(Double value1, Double value2)Returns the minimum of two numbers.static Longmin(Long value1, Long value2)Returns the minimum of two numbers.static Doublepow(Number base, Number exponent)Computes the powerstatic Doublerandom()Returns adoublevalue with a positive sign, greater than or equal to0.0and less than1.0.static Doublerint(Double value)Returns thedoublevalue that is closest in value to the argument and is equal to a mathematical integer.static Longround(Double value)Returns the closestintto the argument.static Doublesin(Number value)Returns the trigonometric sine of an anglestatic Doublesqrt(Number value)Returns the correctly rounded positive square root of adoublevalue.Doublesum(Double[] vals)static Doubletan(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 adoublevalue. 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 adoublevalue.- 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 adoublevalue.- 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)doublevalue 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)doublevalue 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 thedoublevalue that is closest in value to the argument and is equal to a mathematical integer. If twodoublevalues that are mathematical integers are equally close, the result is the integer value that is even.- Parameters:
value- adoublevalue.- Returns:
-
round
public static Long round(Double value)
Returns the closestintto 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
intvalue.
-
random
public static Double random()
Returns adoublevalue with a positive sign, greater than or equal to0.0and less than1.0. Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range.- Returns:
- a pseudorandom
doublegreater than or equal to0.0and less than1.0.
-
-