From 9d0bbf42cb770b78320580cdea6c4104931b1d81 Mon Sep 17 00:00:00 2001 From: Jens Vollinga Date: Thu, 23 Sep 2004 18:38:07 +0000 Subject: [PATCH] Synced bug fix to HEAD. --- ginac/inifcns_nstdsums.cpp | 39 +++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/ginac/inifcns_nstdsums.cpp b/ginac/inifcns_nstdsums.cpp index 17db2c88..16f09691 100644 --- a/ginac/inifcns_nstdsums.cpp +++ b/ginac/inifcns_nstdsums.cpp @@ -507,6 +507,15 @@ static ex Li_evalf(const ex& x1, const ex& x2) if (is_a(x1) && is_a(x2)) { return Li_num(ex_to(x1).to_int(), ex_to(x2)); } + if (is_a(x1) && !is_a(x2)) { + // try to numerically evaluate second argument + ex x2_val = x2.evalf(); + if (is_a(x2_val)) { + return Li_num(ex_to(x1).to_int(), ex_to(x2_val)); + } else { + return Li(x1, x2).hold(); + } + } // multiple polylogs else if (is_a(x1) && is_a(x2)) { ex conv = 1; @@ -1058,8 +1067,15 @@ numeric S_num(int n, int p, const numeric& x) static ex S_evalf(const ex& n, const ex& p, const ex& x) { - if (n.info(info_flags::posint) && p.info(info_flags::posint) && is_a(x)) { - return S_num(ex_to(n).to_int(), ex_to(p).to_int(), ex_to(x)); + if (n.info(info_flags::posint) && p.info(info_flags::posint)) { + if (is_a(x)) { + return S_num(ex_to(n).to_int(), ex_to(p).to_int(), ex_to(x)); + } else { + ex x_val = x.evalf(); + if (is_a(x_val)) { + return S_num(ex_to(n).to_int(), ex_to(p).to_int(), ex_to(x_val)); + } + } } return S(n, p, x).hold(); } @@ -1900,18 +1916,27 @@ cln::cl_N H_do_sum(const std::vector& m, const cln::cl_N& x) static ex H_evalf(const ex& x1, const ex& x2) { - if (is_a(x1) && is_a(x2)) { + if (is_a(x1)) { + + cln::cl_N x; + if (is_a(x2)) { + x = ex_to(x2).to_cl_N(); + } else { + ex x2_val = x2.evalf(); + if (is_a(x2_val)) { + x = ex_to(x2_val).to_cl_N(); + } + } + for (int i=0; i(x2).to_cl_N(); - const lst& morg = ex_to(x1); // remove trailing zeros ... if (*(--morg.end()) == 0) { -- 2.45.1