Class Math


  • public class Math
    extends Object
    Provides implementations of common math functions found in the Math library.
    • Constructor Detail

      • Math

        public Math()
    • Method Detail

      • abs

        public static ScalarValuedFunction abs​(String field)
        Returns the absolute value of the given field.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the absolute value
      • abs

        public static ScalarValuedFunction abs​(ScalarValuedFunction expr)
        Returns the absolute value of the given expression.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the absolute value
      • acos

        public static ScalarValuedFunction acos​(String field)
        Returns the arc cosine of the given field using radians.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the arc cosine
      • acos

        public static ScalarValuedFunction acos​(ScalarValuedFunction expr)
        Returns the arc cosine of the given expression using radians.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the arc cosine
      • asin

        public static ScalarValuedFunction asin​(String field)
        Returns the arc sine of the given field using radians.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the arc sine
      • asin

        public static ScalarValuedFunction asin​(ScalarValuedFunction expr)
        Returns the arc sine of the given expression using radians.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the arc sine
      • atan

        public static ScalarValuedFunction atan​(String field)
        Returns the arc tangent of the given field using radians.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the arc tangent
      • atan

        public static ScalarValuedFunction atan​(ScalarValuedFunction expr)
        Returns the arc tangent of the given expression using radians.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the arc tangent
      • atan2

        public static ScalarValuedFunction atan2​(String y,
                                                 String x)
        Returns the angle theta from the conversion of rectangular coordinates (x,y) to polar coordinates (r, theta).
        Parameters:
        y - the field containing a numeric expression y
        x - the field containing a numeric expression x
        Returns:
        a function that computes theta
      • atan2

        public static ScalarValuedFunction atan2​(ScalarValuedFunction y,
                                                 ScalarValuedFunction x)
        Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta).
        Parameters:
        y - the numeric expression y
        x - the numeric expression x
        Returns:
        a function that computes theta
      • cbrt

        public static ScalarValuedFunction cbrt​(String field)
        Returns the cube root of the given field.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the cube root
      • cbrt

        public static ScalarValuedFunction cbrt​(ScalarValuedFunction expr)
        Returns the cube root of the given expression.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the cube root
      • ceil

        public static ScalarValuedFunction ceil​(String field)
        Returns the ceiling of the given field.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the ceiling
      • ceil

        public static ScalarValuedFunction ceil​(ScalarValuedFunction expr)
        Returns the ceiling of the given expression.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the ceiling
      • copySign

        public static ScalarValuedFunction copySign​(String magnitude,
                                                    String sign)
        Returns magnitude with the sign of sign.
        Parameters:
        magnitude - a field containing a numeric expression
        sign - a field containing a numeric expression
        Returns:
        a function that returns magnitude with the sign of sign
      • cos

        public static ScalarValuedFunction cos​(String field)
        Returns the cosine of the given field using radians.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the cosine
      • cos

        public static ScalarValuedFunction cos​(ScalarValuedFunction expr)
        Returns the cosine of the given expression using radians.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the cosine
      • cosh

        public static ScalarValuedFunction cosh​(String field)
        Returns the hyperbolic cosine of the given field using radians.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the hyperbolic cosine
      • cosh

        public static ScalarValuedFunction cosh​(ScalarValuedFunction expr)
        Returns the hyperbolic cosine of the given expression using radians.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the hyperbolic cosine
      • e

        public static ScalarValuedFunction e()
        Returns the constant value e.
        Returns:
        a constant reference to the double value e
      • exp

        public static ScalarValuedFunction exp​(String field)
        Returns e raised to the power of the given field.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes e raised to a power
      • exp

        public static ScalarValuedFunction exp​(ScalarValuedFunction expr)
        Returns e raised to the power of the given expression.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes e raised to a power
      • expm1

        public static ScalarValuedFunction expm1​(String field)
        Returns e raised to the power of the given field minus 1.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes e raised to a power minus 1
      • expm1

        public static ScalarValuedFunction expm1​(ScalarValuedFunction expr)
        Returns e raised to the power of the given expression minus 1.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes e raised to a power minus 1
      • floor

        public static ScalarValuedFunction floor​(String field)
        Returns the floor of the given field.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the floor
      • floor

        public static ScalarValuedFunction floor​(ScalarValuedFunction expr)
        Returns the floor of the given expression.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the floor
      • getExponent

        public static ScalarValuedFunction getExponent​(String field)
        Returns the unbiased exponent used in the representation of a double or float.
        Parameters:
        field - the field containing a double or float value
        Returns:
        a function that computes the unbiased exponent used in the representation of a double or float
      • getExponent

        public static ScalarValuedFunction getExponent​(ScalarValuedFunction expr)
        Returns the unbiased exponent used in the representation of a double or float.
        Parameters:
        field - a double or float value
        Returns:
        a function that computes the unbiased exponent used in the representation of a double or float
      • hypot

        public static ScalarValuedFunction hypot​(String x,
                                                 String y)
        Returns sqrt(x2 + y2) without intermediate overflow or underflow.
        Parameters:
        x - the field containing a numeric expression x
        y - the field containing a numeric expression y
        Returns:
        a function that computes sqrt(x2 + y2)
      • IEEEremainder

        public static ScalarValuedFunction IEEEremainder​(String dividend,
                                                         String divisor)
        Returns the IEEE 754 standard remainder.
        Parameters:
        dividend - the field containing the dividend numeric expression
        divisor - the field containing the divisor numeric expression
        Returns:
        a function that computes the remainder
      • IEEEremainder

        public static ScalarValuedFunction IEEEremainder​(ScalarValuedFunction dividend,
                                                         ScalarValuedFunction divisor)
        Returns the IEEE 754 standard remainder.
        Parameters:
        dividend - the dividend numeric expression
        divisor - the divisor numeric expression
        Returns:
        a function that computes the remainder
      • log

        public static ScalarValuedFunction log​(String field)
        Returns the natural logarithm of the given field.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the natural logarithm
      • log

        public static ScalarValuedFunction log​(ScalarValuedFunction expr)
        Returns the natural logarithm of the given expression.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the natural logarithm
      • log10

        public static ScalarValuedFunction log10​(String field)
        Returns the base 10 logarithm of the given field.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the base 10 logarithm
      • log10

        public static ScalarValuedFunction log10​(ScalarValuedFunction expr)
        Returns the base 10 logarithm of the given expression.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the base 10 logarithm
      • log1p

        public static ScalarValuedFunction log1p​(String field)
        Returns the natural logarithm of 1 plus the given field.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the natural logarithm of 1 plus a value
      • log1p

        public static ScalarValuedFunction log1p​(ScalarValuedFunction expr)
        Returns the natural logarithm of 1 plus the given expression.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the natural logarithm of 1 plus a value
      • max

        public static ScalarValuedFunction max​(String... fields)
        Returns the maximum of the argument values. If any value is null, the result will be null.
        Parameters:
        fields - the fields containing the first expressions
        Returns:
        a function that returns the max
      • max

        public static ScalarValuedFunction max​(List<ScalarValuedFunction> exprs)
        Returns the maximum of the argument values. If any value is null, the result will be null.
        Parameters:
        exprs - the numeric expressions
        Returns:
        a function that returns the max
      • maxNotNull

        public static ScalarValuedFunction maxNotNull​(String... fields)
        Returns the maximum of the argument values, ignoring null values.
        Parameters:
        fields - the fields containing the first expressions
        Returns:
        a function that returns the max
      • maxNotNull

        public static ScalarValuedFunction maxNotNull​(List<ScalarValuedFunction> exprs)
        Returns the maximum of the argument values, ignoring null values.
        Parameters:
        exprs - the numeric expressions
        Returns:
        a function that returns the max
      • min

        public static ScalarValuedFunction min​(String... fields)
        Returns the minimum of the argument values. If any value is null, the result will be null.
        Parameters:
        fields - the fields containing the numeric expressions
        Returns:
        a function that returns the min
      • min

        public static ScalarValuedFunction min​(List<ScalarValuedFunction> exprs)
        Returns the minimum of the argument values. If any value is null, the result will be null.
        Parameters:
        exprs - the numeric expressions
        Returns:
        a function that returns the min
      • minNotNull

        public static ScalarValuedFunction minNotNull​(String... fields)
        Returns the minimum of the argument values, ignoring null values.
        Parameters:
        fields - the fields containing the numeric expressions
        Returns:
        a function that returns the min
      • minNotNull

        public static ScalarValuedFunction minNotNull​(List<ScalarValuedFunction> exprs)
        Returns the minimum of the argument values, ignoring null values.
        Parameters:
        exprs - the numeric expressions
        Returns:
        a function that returns the min
      • nextAfter

        public static ScalarValuedFunction nextAfter​(String start,
                                                     String direction)
        Returns the floating point number adjacent to the first argument in the direction of the second argument.
        Parameters:
        start - the field containing the start expression
        direction - the field containing the direction expression
        Returns:
        a function that returns the next floating point number
      • nextAfter

        public static ScalarValuedFunction nextAfter​(ScalarValuedFunction start,
                                                     ScalarValuedFunction direction)
        Returns the floating point number adjacent to the first argument in the direction of the second argument.
        Parameters:
        start - the start expression
        direction - the direction expression
        Returns:
        a function that returns the next floating point number
      • nextUp

        public static ScalarValuedFunction nextUp​(String start)
        Returns the floating point number adjacent to the argument in the direction of positive infinity.
        Parameters:
        start - the field containing the start expression
        Returns:
        a function that returns the next floating point number
      • nextUp

        public static ScalarValuedFunction nextUp​(ScalarValuedFunction start)
        Returns the floating point number adjacent to the argument in the direction of positive infinity.
        Parameters:
        start - the start expression
        Returns:
        a function that returns the next floating point number
      • pi

        public static ScalarValuedFunction pi()
        Returns the constant value pi.
        Returns:
        a constant reference to the double value pi
      • pow

        public static ScalarValuedFunction pow​(String base,
                                               String exponent)
        Returns base raised to the exponent power.
        Parameters:
        base - the field containing the base numeric expression
        exponent - the field containing the exponent numeric expression
        Returns:
        a function that computes baseexponent
      • precision

        public static ScalarValuedFunction precision​(String field)
        Returns the precision of the field.
        Parameters:
        field - the field containing the numeric expression
        Returns:
        a function that returns the precision
      • precision

        public static ScalarValuedFunction precision​(ScalarValuedFunction expr)
        Return the precision of the given expression.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that returns the precision
      • random

        public static ScalarValuedFunction random()
        Returns a random double value greater than or equal to 0 and less than 1.
        Returns:
        a function that returns a random value
      • rint

        public static ScalarValuedFunction rint​(String field)
        Returns the double value closest to the given field and equal to a mathematical integer.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that rounds
      • rint

        public static ScalarValuedFunction rint​(ScalarValuedFunction expr)
        Returns the double value closest to the given expression and equal to a mathematical integer.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that rounds
      • round

        public static ScalarValuedFunction round​(String field)
        Returns the expression rounded to the nearest whole number.
        Parameters:
        field - the field containing the numeric expression
        Returns:
        a function that rounds
      • round

        public static ScalarValuedFunction round​(ScalarValuedFunction expr)
        Returns the expression rounded to the nearest whole number.
        Parameters:
        start - the numeric expression
        Returns:
        a function that rounds
      • scalb

        public static ScalarValuedFunction scalb​(String expr,
                                                 String scaleFactor)
        Returns expr × 2scaleFactor rounded as if performed by a single correctly rounded floating-point multiply to a member of the double or float value set.
        Parameters:
        expr - the field containing the base expression
        scaleFactor - the field containing the scale factor
        Returns:
        a function that returns expr × 2scaleFactor
      • scalb

        public static ScalarValuedFunction scalb​(ScalarValuedFunction expr,
                                                 ScalarValuedFunction scaleFactor)
        Returns expr × 2scaleFactor rounded as if performed by a single correctly rounded floating-point multiply to a member of the double or float value set.
        Parameters:
        expr - the base expression
        scaleFactor - the scale factor
        Returns:
        a function that returns expr × 2scaleFactor
      • scale

        public static ScalarValuedFunction scale​(String field)
        Returns the scale of the field.
        Parameters:
        field - the field containing the numeric expression
        Returns:
        a function that returns the scale
      • scale

        public static ScalarValuedFunction scale​(ScalarValuedFunction expr)
        Return the scale of the given expression.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that returns the scale
      • signum

        public static ScalarValuedFunction signum​(String field)
        Returns the signum function of the expression: 0 if the expression is zero, 1 if it is greater than zero, or -1 if it is less than 0.
        Parameters:
        field - the field containing the numeric expression
        Returns:
        a function that returns the signum function
      • signum

        public static ScalarValuedFunction signum​(ScalarValuedFunction expr)
        Returns the signum function of the expression: 0 if the expression is zero, 1 if it is greater than zero, or -1 if it is less than 0.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that returns the signum function
      • sin

        public static ScalarValuedFunction sin​(String field)
        Returns the sine of the given field using radians.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the sine
      • sin

        public static ScalarValuedFunction sin​(ScalarValuedFunction expr)
        Returns the sine of the given expression using radians.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the sine
      • sinh

        public static ScalarValuedFunction sinh​(String field)
        Returns the hyperbolic sine of the given field using radians.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the hyperbolic sine
      • sinh

        public static ScalarValuedFunction sinh​(ScalarValuedFunction expr)
        Returns the hyperbolic sine of the given expression using radians.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the hyperbolic sine
      • sqrt

        public static ScalarValuedFunction sqrt​(String field)
        Returns the square root of the given field.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the square root
      • sqrt

        public static ScalarValuedFunction sqrt​(ScalarValuedFunction expr)
        Returns the square root of the given expression.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the square root
      • tan

        public static ScalarValuedFunction tan​(String field)
        Returns the tangent of the given field using radians.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the tangent
      • tan

        public static ScalarValuedFunction tan​(ScalarValuedFunction expr)
        Returns the tangent of the given expression using radians.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the tangent
      • tanh

        public static ScalarValuedFunction tanh​(String field)
        Returns the hyperbolic tangent of the given field using radians.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that computes the hyperbolic tangent
      • tanh

        public static ScalarValuedFunction tanh​(ScalarValuedFunction expr)
        Returns the hyperbolic tangent of the given expression using radians.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that computes the hyperbolic tangent
      • toDegrees

        public static ScalarValuedFunction toDegrees​(String field)
        Returns the radian expression in degrees.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that converts radians to degrees
      • toDegrees

        public static ScalarValuedFunction toDegrees​(ScalarValuedFunction expr)
        Returns the radian expression in degrees.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that converts radians to degrees
      • toRadians

        public static ScalarValuedFunction toRadians​(String field)
        Returns the degree expression in radians.
        Parameters:
        field - the field containing a numeric expression
        Returns:
        a function that converts degrees to radians
      • toRadians

        public static ScalarValuedFunction toRadians​(ScalarValuedFunction expr)
        Returns the degree expression in radians.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that converts degrees to radians
      • ulp

        public static ScalarValuedFunction ulp​(String field)
        Returns the size of an ulp of the expression.
        Parameters:
        field - the field containing the numeric expression
        Returns:
        a function that returns the ulp size
      • ulp

        public static ScalarValuedFunction ulp​(ScalarValuedFunction expr)
        Returns the size of an ulp of the expression.
        Parameters:
        expr - the numeric expression
        Returns:
        a function that returns the ulp size