14 int Binomial::maxN_ = -1;
15 GArray<int> Binomial::coeffs_;
20 if (maxN <= maxN_)
return;
24 int size = (maxN + 1)*(maxN +2)/2;
26 for (
int i = 0; i < size; ++i) {
32 if (maxN == 0)
return;
34 for (n = 1; n <= maxN; ++n) {
39 for (m = 1; m < n; ++m) {
40 coeffs_[bc + m] = coeffs_[bp + m - 1] + coeffs_[bp + m];
59 if (n > maxN_)
setup(n);
60 return coeffs_[(n*(n+1)/2) + m] ;
static void setup(int nMax)
Precompute all combinations C(n, m) up to n = nMax.
static int coeff(int n, int m)
Return coefficient "n choose m", or C(n, m) = n!/(m!(n-m)!).
static void clear()
Release all static memory.
void resize(int n)
Resizes array so that it contains n elements.
void deallocate()
Deallocate (delete) underlying array of pointers.
int capacity() const
Return physical capacity of array.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Utility classes for scientific computation.