BinomialCoefficients.cc
Go to the documentation of this file.
1 #include <utl/BinomialCoefficients.h>
2 #include <utl/ErrorLogger.h>
3 
4 using namespace utl;
5 
6 
7 void
9 {
10  if (n > 500)
11  WARNING("Are you sure you know what you're doing?");
12 
13  fCoefficients.resize((n+1)*(n+2)/2);
14  for (int i = fMaxN+1; i <= n; ++i) {
15  GetUnchecked(i, 0) = 1;
16  for (int j = 1; j < i; ++j)
17  GetUnchecked(i, j) = GetUnchecked(i-1, j-1) + GetUnchecked(i-1, j);
18  GetUnchecked(i, i) = 1;
19  }
20  fMaxN = n;
21 }
double & GetUnchecked(const int n, const int k)
std::vector< double > fCoefficients
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163

, generated on Tue Sep 26 2023.