]> www.ginac.de Git - ginac.git/commitdiff
G_numeric: fix evaluation with y == 1
authorAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Fri, 12 Sep 2014 13:50:51 +0000 (17:50 +0400)
committerAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Fri, 12 Sep 2014 13:51:11 +0000 (17:51 +0400)
Do apply Hoelder convolution if y == 1 even if there are trailing zeros.
Fixes the regression introduced by commit 97ef604e ("G_numeric: fix
numeric evaluation with trailing zeros and y != 1.")

check/exam_inifcns_nstdsums.cpp
ginac/inifcns_nstdsums.cpp

index d7273bb0fe4f9c2abd0fdc217cd8274537d0920c..7bf1efd1ed486a874a38dc7b66428c1418865929 100644 (file)
@@ -365,6 +365,33 @@ static unsigned inifcns_test_legacy()
        return result;
 }
 
+static unsigned check_G_y_one_bug()
+{
+       exvector exprs;
+       exprs.push_back(G(lst(-1,-1, 1,-1, 0), 1));
+       exprs.push_back(G(lst(-1, 0, 1,-1, 0), 1));
+       exprs.push_back(G(lst(-1, 1,-1,-1, 0), 1));
+       exprs.push_back(G(lst(-1, 1,-1, 0, 0), 1));
+       exprs.push_back(G(lst(-1, 1,-1, 1, 0), 1));
+       exprs.push_back(G(lst(-1, 1, 0,-1, 0), 1));
+       exprs.push_back(G(lst(-1, 1, 1,-1, 0), 1));
+       exprs.push_back(G(lst( 0,-1, 1,-1, 0), 1));
+       exprs.push_back(G(lst( 0, 1, 1,-1, 0), 1));
+       unsigned err = 0;
+       for (exvector::const_iterator ep = exprs.begin(); ep != exprs.end(); ++ep) {
+               try {
+                       ex val = ep->evalf();
+                       if (!is_a<numeric>(val)) {
+                               clog << "evalf(" << *ep << ") is not a number: " << val << endl;
+                               ++err;
+                       }
+               } catch (std::exception& oops) {
+                       clog << "evalf(" << *ep << "): got an exception" << oops.what() << endl;
+                       ++err;
+               }
+       }
+       return err;
+}
 
 unsigned exam_inifcns_nstdsums(void)
 {
@@ -377,6 +404,7 @@ unsigned exam_inifcns_nstdsums(void)
        result += inifcns_test_HLi();
        result += inifcns_test_LiG();
        result += inifcns_test_legacy();
+       result += check_G_y_one_bug();
        
        return result;
 }
index 9f1e2cf0a845e2005256533b76fbb1f45c82b7c5..977642d9c64bf0be58cf7badd789b6843a78e7dd 100644 (file)
@@ -1149,16 +1149,19 @@ G_numeric(const std::vector<cln::cl_N>& x, const std::vector<int>& s,
                                need_hoelder = true;
                }
        }
-       if (zerop(x[x.size() - 1])) {
-               have_trailing_zero = true;
+       have_trailing_zero = zerop(x.back());
+       if (have_trailing_zero) {
                need_trafo = true;
+               if (y != 1) {
+                       need_hoelder = false;
+               }
        }
 
        if (depth == 1 && x.size() == 2 && !need_trafo)
                return - Li_projection(2, y/x[1], cln::float_format(Digits));
        
        // do acceleration transformation (hoelder convolution [BBB])
-       if (need_hoelder && !have_trailing_zero)
+       if (need_hoelder)
                return G_do_hoelder(x, s, y);
        
        // convergence transformation