Package ptolemy.math

Class ExtendedMath


  • public class ExtendedMath
    extends java.lang.Object
    ExtendedMath is a library of additional mathematical operations beyond those provided by the Java Math class.
    Since:
    Ptolemy II 0.2
    Version:
    $Id$
    Author:
    Albert Chen, William Wu, Edward A. Lee, Jeff Tsay
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Yellow (ctsay)
    • Constructor Summary

      Constructors 
      Constructor Description
      ExtendedMath()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double acosh​(double x)
      Return the inverse hyperbolic cosine of the argument.
      static double asinh​(double x)
      Return the inverse hyperbolic sine of the argument.
      static double cosh​(double x)
      Return the hyperbolic cosine of the argument.
      static int gcd​(int u, int v)
      Implement Euclid's method for finding the Greatest Common Divisor (GCD) of two numbers.
      static double log10​(double x)
      Return the base-10 logarithm of the argument.
      static double log2​(double x)
      Return the base-2 logarithm of the argument.
      static double remainder​(double f1, double f2)
      Compute the remainder after dividing the first argument by the second argument as prescribed by the IEEE 754 standard.
      static int roundToInt​(double x)
      Round to the nearest integer.
      static int sgn​(double x)
      If the argument is less than zero, return -1, otherwise return 1.
      static double sinh​(double x)
      Return the hyperbolic sine of the argument.
      static double tanh​(double x)
      Return the hyperbolic tangent of the argument.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SQRT_2

        public static final double SQRT_2
        sqrt(2).
      • ONE_OVER_SQRT_2

        public static final double ONE_OVER_SQRT_2
        1 / sqrt(2).
      • SINGLE_PRECISION_SMALLEST_NORMALIZED_POSITIVE_DOUBLE

        public static final double SINGLE_PRECISION_SMALLEST_NORMALIZED_POSITIVE_DOUBLE
        The smallest, normalized, positive double value with a single precision.
      • DOUBLE_PRECISION_SMALLEST_NORMALIZED_POSITIVE_DOUBLE

        public static final double DOUBLE_PRECISION_SMALLEST_NORMALIZED_POSITIVE_DOUBLE
        The smallest, normalized, positive double value with a double precision.
      • DOUBLE_PRECISION_SIGNIFICAND_ONLY

        public static final double DOUBLE_PRECISION_SIGNIFICAND_ONLY
        The constant value of a double representation that has all bits as 1 except the sign bit, where only the significand contributes to the value. This value is equal to 1 + 1/2 + 1/2^2 + 1/2^3 + ... + 1/2^m, where m is the number of bits for the significand. M is 52 for a double precision floating point number.
      • SINGLE_PRECISION_SIGNIFICAND_ONLY

        public static final double SINGLE_PRECISION_SIGNIFICAND_ONLY
        The constant value of a double representation that has all bits as 1 except the sign bit, where only the significand contributes to the value. This value is equal to 1 + 1/2 + 1/2^2 + 1/2^3 + ... + 1/2^m, where m is the number of bits for the significand. M is 23 for a single precision floating point number.
    • Constructor Detail

      • ExtendedMath

        public ExtendedMath()
    • Method Detail

      • acosh

        public static final double acosh​(double x)
        Return the inverse hyperbolic cosine of the argument. The argument is required to be greater than one, or an IllegalArgumentException is thrown (this is a runtime exception, so it need not be declared). The returned value is positive.
      • asinh

        public static final double asinh​(double x)
        Return the inverse hyperbolic sine of the argument.
      • cosh

        public static final double cosh​(double x)
        Return the hyperbolic cosine of the argument.
      • gcd

        public static int gcd​(int u,
                              int v)
        Implement Euclid's method for finding the Greatest Common Divisor (GCD) of two numbers. If the numbers are negative, then we compute the GCD of their absolute values.
      • log10

        public static final double log10​(double x)
        Return the base-10 logarithm of the argument.
      • log2

        public static final double log2​(double x)
        Return the base-2 logarithm of the argument.
      • remainder

        public static double remainder​(double f1,
                                       double f2)
        Compute the remainder after dividing the first argument by the second argument as prescribed by the IEEE 754 standard. This is implemented by the java.lang.Math class method IEEERemainder. The documentation for that class says:

        "The remainder value is mathematically equal to f1 - f2 × n, where n is the mathematical integer closest to the exact mathematical value of the quotient f1/f2, and if two mathematical integers are equally close to f1/f2, then n is the integer that is even. If the remainder is zero, its sign is the same as the sign of the first argument. Special cases:

        • If either argument is NaN, or the first argument is infinite, or the second argument is positive zero or negative zero, then the result is NaN.
        • If the first argument is finite and the second argument is infinite, then the result is the same as the first argument.
      • roundToInt

        public static final int roundToInt​(double x)
        Round to the nearest integer. If the argument is NaN, then the return value is 0. If the argument is out of range, then the return value is Integer.MAX_VALUE or Integer.MIN_VALUE, depending on the sign of the argument.
        Parameters:
        x - The number to round.
        Returns:
        The nearest integer.
      • sgn

        public static final int sgn​(double x)
        If the argument is less than zero, return -1, otherwise return 1.
      • sinh

        public static final double sinh​(double x)
        Return the hyperbolic sine of the argument.
      • tanh

        public static final double tanh​(double x)
        Return the hyperbolic tangent of the argument.