ptolemy.math
Class ExtendedMath

java.lang.Object
  extended by ptolemy.math.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: ExtendedMath.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Albert Chen, William Wu, Edward A. Lee, Jeff Tsay
Accepted Rating:
Red (cxh)
Proposed Rating:
Yellow (ctsay)

Field Summary
private static double _ONEOVERLN10
           
private static double _ONEOVERLN2
           
static 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.
static double DOUBLE_PRECISION_SMALLEST_NORMALIZED_POSITIVE_DOUBLE
          The smallest, normalized, positive double value with a double precision.
static double ONE_OVER_SQRT_2
          1 / sqrt(2).
static double PI_OVER_2
          PI / 2.
static double PI_OVER_4
          PI / 4.
static 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.
static double SINGLE_PRECISION_SMALLEST_NORMALIZED_POSITIVE_DOUBLE
          The smallest, normalized, positive double value with a single precision.
static double SQRT_2
          sqrt(2).
 
Constructor Summary
ExtendedMath()
           
 
Method Summary
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).


PI_OVER_2

public static final double PI_OVER_2
PI / 2.

See Also:
Constant Field Values

PI_OVER_4

public static final double PI_OVER_4
PI / 4.

See Also:
Constant Field Values

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.


_ONEOVERLN2

private static final double _ONEOVERLN2

_ONEOVERLN10

private static final double _ONEOVERLN10
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:


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.