From 9e80b0d339d1ce83f51e0eb5fb101c41f23f6a71 Mon Sep 17 00:00:00 2001 From: Alexei Sheplyakov Date: Fri, 12 Sep 2014 17:50:51 +0400 Subject: [PATCH] G_numeric: fix evaluation with y == 1 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 | 28 ++++++++++++++++++++++++++++ ginac/inifcns_nstdsums.cpp | 9 ++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/check/exam_inifcns_nstdsums.cpp b/check/exam_inifcns_nstdsums.cpp index d7273bb0..7bf1efd1 100644 --- a/check/exam_inifcns_nstdsums.cpp +++ b/check/exam_inifcns_nstdsums.cpp @@ -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(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; } diff --git a/ginac/inifcns_nstdsums.cpp b/ginac/inifcns_nstdsums.cpp index 9f1e2cf0..977642d9 100644 --- a/ginac/inifcns_nstdsums.cpp +++ b/ginac/inifcns_nstdsums.cpp @@ -1149,16 +1149,19 @@ G_numeric(const std::vector& x, const std::vector& 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 -- 2.44.0