]> www.ginac.de Git - ginac.git/commitdiff
Fixed bug in mLi summation causing premature drop-out and made Nielsen polylog
authorJens Vollinga <jensv@nikhef.nl>
Fri, 4 Apr 2008 12:48:19 +0000 (14:48 +0200)
committerJens Vollinga <jensv@nikhef.nl>
Fri, 4 Apr 2008 12:52:18 +0000 (14:52 +0200)
invalidate its lookup tables if precision has been changed.

ginac/inifcns_nstdsums.cpp

index 138f5e34431acb0d1b72b1e378a8ee0200d44726..43add2803c969b4107457ec8f995914d368d6021 100644 (file)
@@ -489,7 +489,6 @@ cln::cl_N multipleLi_do_sum(const std::vector<int>& s, const std::vector<cln::cl
                q++;
                t[j-1] = t[j-1] + cln::expt(x[j-1], q) / cln::expt(cln::cl_I(q),s[j-1]) * one;
                for (int k=j-2; k>=0; k--) {
                q++;
                t[j-1] = t[j-1] + cln::expt(x[j-1], q) / cln::expt(cln::cl_I(q),s[j-1]) * one;
                for (int k=j-2; k>=0; k--) {
-                       flag_accidental_zero = cln::zerop(t[k+1]);
                        t[k] = t[k] + t[k+1] * cln::expt(x[k], q+j-1-k) / cln::expt(cln::cl_I(q+j-1-k), s[k]);
                }
                q++;
                        t[k] = t[k] + t[k+1] * cln::expt(x[k], q+j-1-k) / cln::expt(cln::cl_I(q+j-1-k), s[k]);
                }
                q++;
@@ -498,7 +497,7 @@ cln::cl_N multipleLi_do_sum(const std::vector<int>& s, const std::vector<cln::cl
                        flag_accidental_zero = cln::zerop(t[k+1]);
                        t[k] = t[k] + t[k+1] * cln::expt(x[k], q+j-1-k) / cln::expt(cln::cl_I(q+j-1-k), s[k]);
                }
                        flag_accidental_zero = cln::zerop(t[k+1]);
                        t[k] = t[k] + t[k+1] * cln::expt(x[k], q+j-1-k) / cln::expt(cln::cl_I(q+j-1-k), s[k]);
                }
-       } while ( (t[0] != t0buf) || flag_accidental_zero );
+       } while ( (t[0] != t0buf) || cln::zerop(t[0]) || flag_accidental_zero );
 
        return t[0];
 }
 
        return t[0];
 }
@@ -1810,10 +1809,20 @@ cln::cl_N b_k(int k)
 // helper function for S(n,p,x)
 cln::cl_N S_do_sum(int n, int p, const cln::cl_N& x, const cln::float_format_t& prec)
 {
 // helper function for S(n,p,x)
 cln::cl_N S_do_sum(int n, int p, const cln::cl_N& x, const cln::float_format_t& prec)
 {
+       static cln::float_format_t oldprec = cln::default_float_format;
+
        if (p==1) {
                return Li_projection(n+1, x, prec);
        }
        if (p==1) {
                return Li_projection(n+1, x, prec);
        }
-       
+
+       // precision has changed, we need to clear lookup table Yn
+       if ( oldprec != prec ) {
+               Yn.clear();
+               ynsize = 0;
+               ynlength = 100;
+               oldprec = prec;
+       }
+               
        // check if precalculated values are sufficient
        if (p > ynsize+1) {
                for (int i=ynsize; i<p-1; i++) {
        // check if precalculated values are sufficient
        if (p > ynsize+1) {
                for (int i=ynsize; i<p-1; i++) {