From be11202909f8014b213065ca85272af403a530f1 Mon Sep 17 00:00:00 2001 From: Stefan Weinzierl Date: Wed, 24 Mar 2021 09:43:26 +0100 Subject: [PATCH] G_do_hoelder: fix bug related to comparing a float with a rational number in CLN. This bug has been reported by Simone Zoia. --- ginac/inifcns_nstdsums.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/ginac/inifcns_nstdsums.cpp b/ginac/inifcns_nstdsums.cpp index 66c0542d..c6f5012a 100644 --- a/ginac/inifcns_nstdsums.cpp +++ b/ginac/inifcns_nstdsums.cpp @@ -1013,21 +1013,25 @@ G_do_hoelder(std::vector x, /* yes, it's passed by value */ for (std::size_t i = 0; i < size; ++i) x[i] = x[i]/y; + // 24.03.2021: this block can be outside the loop over r + cln::cl_RA p(2); + bool adjustp; + do { + adjustp = false; + for (std::size_t i = 0; i < size; ++i) { + // 24.03.2021: replaced (x[i] == cln::cl_RA(1)/p) by (cln::zerop(x[i] - cln::cl_RA(1)/p) + // in the case where we compare a float with a rational, CLN behaves differently in the two versions + if (cln::zerop(x[i] - cln::cl_RA(1)/p) ) { + p = p/2 + cln::cl_RA(3)/2; + adjustp = true; + continue; + } + } + } while (adjustp); + cln::cl_RA q = p/(p-1); + for (std::size_t r = 0; r <= size; ++r) { cln::cl_N buffer(1 & r ? -1 : 1); - cln::cl_RA p(2); - bool adjustp; - do { - adjustp = false; - for (std::size_t i = 0; i < size; ++i) { - if (x[i] == cln::cl_RA(1)/p) { - p = p/2 + cln::cl_RA(3)/2; - adjustp = true; - continue; - } - } - } while (adjustp); - cln::cl_RA q = p/(p-1); std::vector qlstx; std::vector qlsts; for (std::size_t j = r; j >= 1; --j) { -- 2.44.0