Calculates binomial coefficients and caches the results. More...
#include "utl/BinomialCoefficients.h"
Public Member Functions | |
BinomialCoefficients (const int initialN=3) | |
double | operator() (const int n, const int k) |
Public Attributes | |
static BinomialCoefficients &return | instance |
Private Member Functions | |
void | Generate (const int n) |
double & | GetUnchecked (const int n, const int k) |
Private Attributes | |
std::vector< double > | fCoefficients |
int | fMaxN |
Calculates binomial coefficients and caches the results.
Call to the class' operator(n, k) is equivalent to binomial coefficient .
Due to rounding errors for the explicit formula with factorials (division of large numbers) this generator is using the Pascal triangle relations instead, i.e.
where only addition of moderate sized numbers can be maintained even for fairly large n.
Usage:
Definition at line 38 of file BinomialCoefficients.h.
|
inline |
Definition at line 40 of file BinomialCoefficients.h.
References Generate().
|
private |
Definition at line 8 of file BinomialCoefficients.cc.
References fCoefficients, fMaxN, GetUnchecked(), and WARNING.
Referenced by BinomialCoefficients(), and operator()().
|
inlineprivate |
Definition at line 54 of file BinomialCoefficients.h.
References fCoefficients.
Referenced by Generate(), and operator()().
|
inline |
Definition at line 44 of file BinomialCoefficients.h.
References fMaxN, Generate(), and GetUnchecked().
|
private |
Definition at line 60 of file BinomialCoefficients.h.
Referenced by Generate(), and GetUnchecked().
|
private |
Definition at line 59 of file BinomialCoefficients.h.
Referenced by Generate(), and operator()().
|
inherited |
Definition at line 44 of file Singleton.h.