public final class BinomialCoef extends java.lang.Object implements javolution.lang.ValueType, SizedObject
This class represents an immutable matrix of binomial coefficients (n/k) defined up to a specified maximum index.
( n ) n! ( ) = -------- 0 <= k <= n ( k ) k!(n-k)!
Reference: http://en.wikipedia.org/wiki/Binomial_coefficient
Modified by: Joseph A. Huwaldt
Modifier and Type | Method and Description |
---|---|
BinomialCoef |
copy()
Returns a copy of this binomial coefficient matrix
allocated by the calling thread
(possibly on the stack). |
double |
get(int n,
int k)
Return the specified binomial coefficient (n / k)
|
static BinomialCoef |
newInstance(int size)
Returns a
BinomialCoef instance holding the coefficients (at least) up to
the specified size. |
static void |
recycle(BinomialCoef instance)
Recycles a
BinomialCoef instance immediately (on the stack when
executing in a StackContext). |
int |
size()
Return the size of the binomial coefficient matrix (the maximum binomial index
value: (N/N)).
|
javolution.text.Text |
toText()
Returns the text representation of this binomial coefficient matrix.
|
public static BinomialCoef newInstance(int size)
BinomialCoef
instance holding the coefficients (at least) up to
the specified size. The returned instance may be recycled and may contain more
coefficients than the requested size.size
- the desired size to compute coefficients for:
N = size - 1 ==> (N/N)
or size = N + 1
.public int size()
size
in interface SizedObject
public double get(int n, int k)
n
- The 1st index into the binomial coefficient matrix (n / k). Must be <
size().k
- The 2nd index into the binomial coefficient matrix (n / k). Must be <
size().public BinomialCoef copy()
allocated
by the calling thread
(possibly on the stack).copy
in interface javolution.lang.ValueType
public static void recycle(BinomialCoef instance)
BinomialCoef
instance immediately (on the stack when
executing in a StackContext).public javolution.text.Text toText()