]> www.ginac.de Git - ginac.git/blobdiff - ginac/inifcns_nstdsums.cpp
Fixed bug in convergence check with complex arguments.
[ginac.git] / ginac / inifcns_nstdsums.cpp
index 6217d8b5b2901ace0eb1cd547781cdaf03d0f465..4fe91ad391eeb7f41e40362c7fa67223339da3a6 100644 (file)
@@ -189,7 +189,7 @@ cln::cl_N Li2_do_sum(const cln::cl_N& x)
 {
        cln::cl_N res = x;
        cln::cl_N resbuf;
 {
        cln::cl_N res = x;
        cln::cl_N resbuf;
-       cln::cl_N num = x;
+       cln::cl_N num = x * cln::cl_float(1, cln::float_format(Digits));
        cln::cl_I den = 1; // n^2 = 1
        unsigned i = 3;
        do {
        cln::cl_I den = 1; // n^2 = 1
        unsigned i = 3;
        do {
@@ -208,7 +208,7 @@ cln::cl_N Li2_do_sum_Xn(const cln::cl_N& x)
 {
        std::vector<cln::cl_N>::const_iterator it = Xn[0].begin();
        cln::cl_N u = -cln::log(1-x);
 {
        std::vector<cln::cl_N>::const_iterator it = Xn[0].begin();
        cln::cl_N u = -cln::log(1-x);
-       cln::cl_N factor = u;
+       cln::cl_N factor = u * cln::cl_float(1, cln::float_format(Digits));
        cln::cl_N res = u - u*u/4;
        cln::cl_N resbuf;
        unsigned i = 1;
        cln::cl_N res = u - u*u/4;
        cln::cl_N resbuf;
        unsigned i = 1;
@@ -226,7 +226,7 @@ cln::cl_N Li2_do_sum_Xn(const cln::cl_N& x)
 // calculates Li(n,x), n>2 without Xn
 cln::cl_N Lin_do_sum(int n, const cln::cl_N& x)
 {
 // calculates Li(n,x), n>2 without Xn
 cln::cl_N Lin_do_sum(int n, const cln::cl_N& x)
 {
-       cln::cl_N factor = x;
+       cln::cl_N factor = x * cln::cl_float(1, cln::float_format(Digits));
        cln::cl_N res = x;
        cln::cl_N resbuf;
        int i=2;
        cln::cl_N res = x;
        cln::cl_N resbuf;
        int i=2;
@@ -245,7 +245,7 @@ cln::cl_N Lin_do_sum_Xn(int n, const cln::cl_N& x)
 {
        std::vector<cln::cl_N>::const_iterator it = Xn[n-2].begin();
        cln::cl_N u = -cln::log(1-x);
 {
        std::vector<cln::cl_N>::const_iterator it = Xn[n-2].begin();
        cln::cl_N u = -cln::log(1-x);
-       cln::cl_N factor = u;
+       cln::cl_N factor = u * cln::cl_float(1, cln::float_format(Digits));
        cln::cl_N res = u;
        cln::cl_N resbuf;
        unsigned i=2;
        cln::cl_N res = u;
        cln::cl_N resbuf;
        unsigned i=2;
@@ -461,7 +461,7 @@ static ex Li_evalf(const ex& x1, const ex& x2)
                                return Li(x1, x2).hold();
                        }
                        conv *= x2.op(i);
                                return Li(x1, x2).hold();
                        }
                        conv *= x2.op(i);
-                       if (conv >= 1) {
+                       if (abs(conv) >= 1) {
                                return Li(x1, x2).hold();
                        }
                }
                                return Li(x1, x2).hold();
                        }
                }
@@ -846,7 +846,9 @@ cln::cl_N S_do_sum(int n, int p, const cln::cl_N& x, const cln::float_format_t&
        }
 
        // should be done otherwise
        }
 
        // should be done otherwise
-       cln::cl_N xf = x * cln::cl_float(1, prec);
+       cln::cl_F one = cln::cl_float(1, cln::float_format(Digits));
+       cln::cl_N xf = x * one;
+       //cln::cl_N xf = x * cln::cl_float(1, prec);
 
        cln::cl_N res;
        cln::cl_N resbuf;
 
        cln::cl_N res;
        cln::cl_N resbuf;
@@ -1141,10 +1143,6 @@ bool convert_parameter_H_to_Li(const lst& l, lst& m, lst& s, ex& pf)
                        }
                }
        }
                        }
                }
        }
-       for (; acc > 1; acc--) {
-               throw std::runtime_error("ERROR!");
-               m.append(0);
-       }
        
        return has_negative_parameters;
 }
        
        return has_negative_parameters;
 }
@@ -2035,25 +2033,25 @@ static ex H_eval(const ex& m_, const ex& x)
        if ((x == _ex1) && (*(--m.end()) != _ex0)) {
                return convert_H_to_zeta(m);
        }
        if ((x == _ex1) && (*(--m.end()) != _ex0)) {
                return convert_H_to_zeta(m);
        }
-       if (step == 0) {
-               if (pos1 == _ex0) {
-                       // all zero
-                       if (x == _ex0) {
-                               return H(m_, x).hold();
-                       }
-                       return pow(log(x), m.nops()) / factorial(m.nops());
-               } else {
-                       // all (minus) one
-                       return pow(-pos1*log(1-pos1*x), m.nops()) / factorial(m.nops());
-               }
-       } else if ((step == 1) && (pos1 == _ex0)){
-               // convertible to S
-               if (pos2 == _ex1) {
-                       return S(n, p, x);
-               } else {
-                       return pow(-1, p) * S(n, p, -x);
-               }
-       }
+//     if (step == 0) {
+//             if (pos1 == _ex0) {
+//                     // all zero
+//                     if (x == _ex0) {
+//                             return H(m_, x).hold();
+//                     }
+//                     return pow(log(x), m.nops()) / factorial(m.nops());
+//             } else {
+//                     // all (minus) one
+//                     return pow(-pos1*log(1-pos1*x), m.nops()) / factorial(m.nops());
+//             }
+//     } else if ((step == 1) && (pos1 == _ex0)){
+//             // convertible to S
+//             if (pos2 == _ex1) {
+//                     return S(n, p, x);
+//             } else {
+//                     return pow(-1, p) * S(n, p, -x);
+//             }
+//     }
        if (x == _ex0) {
                return _ex0;
        }
        if (x == _ex0) {
                return _ex0;
        }
@@ -2141,9 +2139,9 @@ ex convert_H_to_Li(const ex& m, const ex& x)
        map_trafo_H_reduce_trailing_zeros filter;
        map_trafo_H_convert_to_Li filter2;
        if (is_a<lst>(m)) {
        map_trafo_H_reduce_trailing_zeros filter;
        map_trafo_H_convert_to_Li filter2;
        if (is_a<lst>(m)) {
-               return filter2(filter(H(m, x).hold())).eval();
+               return filter2(filter(H(m, x).hold()));
        } else {
        } else {
-               return filter2(filter(H(lst(m), x).hold())).eval();
+               return filter2(filter(H(lst(m), x).hold()));
        }
 }
 
        }
 }