33 namespace algorithms {
40 static std::vector<double> f(10);
41 static bool first=
true;
45 for(
int j=2;j<10;j++) f[j] = f[j-1]*(
double)j;
48 if (i>=(
int)f.size()) {
50 #pragma omp critical (fact)
53 for(
int j=f.size();j<=i;j++)
54 f.push_back(f[j-1]*(
double)j);
56 assert(i==(
int)f.size()-1);
58 assert(i<(
int)f.size());
65 static std::vector<double> f(10);
66 static bool first=
true;
69 for(
int j=2;j<10;j++) f[j] = f[j-1]*sqrt((
double)j);
72 if (i>=(
int)f.size()) {
74 #pragma omp critical (sqrtfact)
77 for(
int j=f.size();j<=i;j++)
78 f.push_back(f[j-1]*sqrt((
double)j));
81 assert(i<(
int)f.size());
88 static std::vector<std::vector<double> > f(10);
89 static bool first=
true;
91 f[0] = std::vector<double>(1,1.);
92 f[1] = std::vector<double>(2,1.);
93 for(
int i1=2;i1<10;i1++) {
94 f[i1] = std::vector<double>(i1+1);
95 f[i1][0] = f[i1][i1] = 1.;
96 for(
int j1=1;j1<i1;j1++) f[i1][j1] = f[i1-1][j1-1] + f[i1-1][j1];
100 if (i>=(
int)f.size()) {
102 #pragma omp critical (binom)
105 for(
int i1=f.size();i1<=i;i1++) {
106 f.push_back(std::vector<double>(i1+1,1.));
107 for(
int j1=1;j1<i1;j1++) f[i1][j1] = f[i1-1][j1-1] + f[i1-1][j1];
110 assert(i==(
int)f.size()-1);
112 if (j<0 || j>i)
return 0.;
113 assert(i<(
int)f.size());
114 assert(j<(
int)f[i].size());
121 static std::vector<double> f(10);
122 static bool first=
true;
124 for(
int j=0;j<10;j++) f[j] = std::sqrt((
double)j);
127 if (i>=(
int)f.size()) {
129 #pragma omp critical (sqrtn)
132 for(
int j=f.size();j<=i;j++)
133 f.push_back(std::sqrt((
double)j));
136 assert(i<(
int)f.size());
double binom(int i, int j)