Pass the f_kj coefficients as an arguments to crandall_Z and calc_f
functions instead of using global variables.
// parameters and data for [Cra] algorithm
const cln::cl_N lambda = cln::cl_N("319/320");
// parameters and data for [Cra] algorithm
const cln::cl_N lambda = cln::cl_N("319/320");
-std::vector<std::vector<cln::cl_N> > f_kj;
std::vector<cln::cl_N> crB;
std::vector<std::vector<cln::cl_N> > crG;
std::vector<cln::cl_N> crX;
std::vector<cln::cl_N> crB;
std::vector<std::vector<cln::cl_N> > crG;
std::vector<cln::cl_N> crX;
+static void calc_f(std::vector<std::vector<cln::cl_N> >& f_kj,
+ const int maxr, const int L1)
- f_kj.clear();
- f_kj.resize(L1);
-
cln::cl_N t0, t1, t2, t3, t4;
int i, j, k;
std::vector<std::vector<cln::cl_N> >::iterator it = f_kj.begin();
cln::cl_N t0, t1, t2, t3, t4;
int i, j, k;
std::vector<std::vector<cln::cl_N> >::iterator it = f_kj.begin();
-cln::cl_N crandall_Z(const std::vector<int>& s)
+static cln::cl_N crandall_Z(const std::vector<int>& s,
+ const std::vector<std::vector<cln::cl_N> >& f_kj)
{
const int j = s.size();
{
const int j = s.size();
std::vector<int> r = s;
const int j = r.size();
std::vector<int> r = s;
const int j = r.size();
// decide on maximal size of f_kj for crandall_Z
if (Digits < 50) {
L1 = 150;
// decide on maximal size of f_kj for crandall_Z
if (Digits < 50) {
L1 = 150;
+ std::vector<std::vector<cln::cl_N> > f_kj(L1);
+ calc_f(f_kj, maxr, L1);
const cln::cl_N r0factorial = cln::factorial(r[0]-1);
const cln::cl_N r0factorial = cln::factorial(r[0]-1);
for (int q=0; q<skp1buf; q++) {
cln::cl_N pp1 = crandall_Y_loop(Srun+q-k);
for (int q=0; q<skp1buf; q++) {
cln::cl_N pp1 = crandall_Y_loop(Srun+q-k);
- cln::cl_N pp2 = crandall_Z(rz);
+ cln::cl_N pp2 = crandall_Z(rz, f_kj);
- res = (res + crandall_Y_loop(S-j)) / r0factorial + crandall_Z(rz);
+ res = (res + crandall_Y_loop(S-j)) / r0factorial + crandall_Z(rz, f_kj);