14 int Binomial::maxN_ = -1;
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];
49 if (coeffs_.capacity() > 0) {
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!
static void clear()
Release all static memory.
An automatically growable array, analogous to a std::vector.
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.