org.apache.commons.math.util
Class MathUtils

java.lang.Object
  extended byorg.apache.commons.math.util.MathUtils

public final class MathUtils
extends Object

Some useful additions to the built-in functions in Math.

Version:
$Revision: 1.9 $ $Date: 2003/11/14 22:22:17 $

Method Summary
static long binomialCoefficient(int n, int k)
          Returns an exact representation of the Binomial Coefficient, "n choose k", the number of k-element subsets that can be selected from an n-element set.
static double binomialCoefficientDouble(int n, int k)
          Returns a double representation of the Binomial Coefficient, "n choose k", the number of k-element subsets that can be selected from an n-element set.
static double binomialCoefficientLog(int n, int k)
          Returns the natural log of the Binomial Coefficient, "n choose k", the number of k-element subsets that can be selected from an n-element set.
static double cosh(double x)
           
static long factorial(int n)
          Returns n!.
static double factorialDouble(int n)
          Returns n!.
static double factorialLog(int n)
          Returns the natural logarithm of n!.
static byte sign(byte x)
          For a byte value x, this method returns (byte)(+1) if x >= 0 and (byte)(-1) if x < 0.
static double sign(double x)
          For a double precision value x, this method returns +1.0 if x >= 0 and -1.0 if x < 0.
static float sign(float x)
          For a float value x, this method returns +1.0F if x >= 0 and -1.0F if x < 0.
static int sign(int x)
          For an int value x, this method returns +1 if x >= 0 and -1 if x < 0.
static long sign(long x)
          For a long value x, this method returns +1L if x >= 0 and -1L if x < 0.
static short sign(short x)
          For a short value x, this method returns (short)(+1) if x >= 0 and (short)(-1) if x < 0.
static double sinh(double x)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sign

public static double sign(double x)
For a double precision value x, this method returns +1.0 if x >= 0 and -1.0 if x < 0.

Parameters:
x - the value, a double
Returns:
+1.0 or -1.0, depending on the the sign of x

sign

public static float sign(float x)
For a float value x, this method returns +1.0F if x >= 0 and -1.0F if x < 0.

Parameters:
x - the value, a float
Returns:
+1.0F or -1.0F, depending on the the sign of x

sign

public static byte sign(byte x)
For a byte value x, this method returns (byte)(+1) if x >= 0 and (byte)(-1) if x < 0.

Parameters:
x - the value, a byte
Returns:
(byte)(+1) or (byte)(-1), depending on the the sign of x

sign

public static short sign(short x)
For a short value x, this method returns (short)(+1) if x >= 0 and (short)(-1) if x < 0.

Parameters:
x - the value, a short
Returns:
(short)(+1) or (short)(-1), depending on the the sign of x

sign

public static int sign(int x)
For an int value x, this method returns +1 if x >= 0 and -1 if x < 0.

Parameters:
x - the value, an int
Returns:
+1 or -1, depending on the the sign of x

sign

public static long sign(long x)
For a long value x, this method returns +1L if x >= 0 and -1L if x < 0.

Parameters:
x - the value, a long
Returns:
+1L or -1L, depending on the the sign of x

binomialCoefficient

public static long binomialCoefficient(int n,
                                       int k)
Returns an exact representation of the Binomial Coefficient, "n choose k", the number of k-element subsets that can be selected from an n-element set.

Preconditions:

Parameters:
n - the size of the set
k - the size of the subsets to be counted
Returns:
n choose k

binomialCoefficientDouble

public static double binomialCoefficientDouble(int n,
                                               int k)
Returns a double representation of the Binomial Coefficient, "n choose k", the number of k-element subsets that can be selected from an n-element set.

Preconditions:

Parameters:
n - the size of the set
k - the size of the subsets to be counted
Returns:
n choose k

binomialCoefficientLog

public static double binomialCoefficientLog(int n,
                                            int k)
Returns the natural log of the Binomial Coefficient, "n choose k", the number of k-element subsets that can be selected from an n-element set.

Preconditions:

Parameters:
n - the size of the set
k - the size of the subsets to be counted
Returns:
n choose k

factorial

public static long factorial(int n)
Returns n!. Shorthand for n Factorial, the product of the numbers 1,...,n.

Preconditions:

Parameters:
n - argument
Returns:
n!

factorialDouble

public static double factorialDouble(int n)
Returns n!. Shorthand for n Factorial, the product of the numbers 1,...,n as a double.

Preconditions:

Parameters:
n - argument
Returns:
n!

factorialLog

public static double factorialLog(int n)
Returns the natural logarithm of n!.

Preconditions:

Parameters:
n - argument
Returns:
n!

cosh

public static double cosh(double x)

sinh

public static double sinh(double x)


Copyright © 2003-2004 Apache Software Foundation. All Rights Reserved.