From 773570d668a8a86d4c646dfe9d8572746329652c Mon Sep 17 00:00:00 2001 From: Alexei Sheplyakov Date: Fri, 29 Aug 2008 23:44:51 +0400 Subject: [PATCH] multiple zeta values: make crandall_Z helper function reentrant. Pass the f_kj coefficients as an arguments to crandall_Z and calc_f functions instead of using global variables. --- ginac/inifcns_nstdsums.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ginac/inifcns_nstdsums.cpp b/ginac/inifcns_nstdsums.cpp index bf5ce093..22e31251 100644 --- a/ginac/inifcns_nstdsums.cpp +++ b/ginac/inifcns_nstdsums.cpp @@ -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 > f_kj; std::vector crB; std::vector > crG; std::vector 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 >& 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 >::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& s) +static cln::cl_N crandall_Z(const std::vector& s, + const std::vector >& f_kj) { const int j = s.size(); @@ -3564,6 +3561,8 @@ cln::cl_N zeta_do_sum_Crandall(const std::vector& s) std::vector 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& s) } } - calc_f(maxr); + std::vector > 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& s) for (int q=0; q& 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; } -- 2.44.0