]> www.ginac.de Git - ginac.git/commitdiff
multiple zeta values: make crandall_Z helper function reentrant.
authorAlexei Sheplyakov <varg@theor.jinr.ru>
Fri, 29 Aug 2008 19:44:51 +0000 (23:44 +0400)
committerAlexei Sheplyakov <varg@theor.jinr.ru>
Tue, 9 Sep 2008 08:33:46 +0000 (12:33 +0400)
Pass the f_kj coefficients as an arguments to crandall_Z and calc_f
functions instead of using global variables.

ginac/inifcns_nstdsums.cpp

index bf5ce093165cb7b30d15f410f7f72e5f23582d2d..22e3125198b1ba12712c4b5af77d6c678b1e7481 100644 (file)
@@ -3417,9 +3417,7 @@ namespace {
 
 // parameters and data for [Cra] algorithm
 const cln::cl_N lambda = cln::cl_N("319/320");
-int L1;
 int L2;
-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;
@@ -3493,11 +3491,9 @@ cln::cl_N crandall_Y_loop(const cln::cl_N& Sqk)
 
 
 // [Cra] section 4
-void calc_f(int maxr)
+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();
@@ -3523,7 +3519,8 @@ void calc_f(int maxr)
 
 
 // [Cra] (3.1)
-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();
 
@@ -3564,6 +3561,8 @@ cln::cl_N zeta_do_sum_Crandall(const std::vector<int>& s)
        std::vector<int> r = s;
        const int j = r.size();
 
+       std::size_t L1;
+
        // decide on maximal size of f_kj for crandall_Z
        if (Digits < 50) {
                L1 = 150;
@@ -3597,7 +3596,8 @@ cln::cl_N zeta_do_sum_Crandall(const std::vector<int>& s)
                }
        }
 
-       calc_f(maxr);
+       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);
 
@@ -3616,7 +3616,7 @@ cln::cl_N zeta_do_sum_Crandall(const std::vector<int>& s)
                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);
 
                        rz.front()--;
                        
@@ -3632,7 +3632,7 @@ cln::cl_N zeta_do_sum_Crandall(const std::vector<int>& s)
 
        initcX(rz);
 
-       res = (res + crandall_Y_loop(S-j)) / r0factorial + crandall_Z(rz);
+       res = (res + crandall_Y_loop(S-j)) / r0factorial + crandall_Z(rz, f_kj);
 
        return res;
 }