From 5acfced77964d811d66f83e83b8fa06d77f3edd0 Mon Sep 17 00:00:00 2001 From: Stefan Weinzierl Date: Tue, 28 Jan 2014 08:58:06 +0200 Subject: [PATCH] Li_eval(): avoid the "numeric::operator>(): complex inequality" exception. Basically the problem is that 1 + 0.0*I is equal to 1, but checking if the former is positive results in the the "numeric::operator>(): complex inequality" exception. This behavior is definitely inconsistent and should be fixed. As a work around teach Li_eval and convert_parameter_Li_to_H to explicitly convert 1 + 0.0*I to 1 (and -1 + 0.0*I to -1, respectively). [Alexei Sheplyakov: comment the code a little bit, otherwise it looks weird] --- ginac/inifcns_nstdsums.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ginac/inifcns_nstdsums.cpp b/ginac/inifcns_nstdsums.cpp index 9876075c..975a81e6 100644 --- a/ginac/inifcns_nstdsums.cpp +++ b/ginac/inifcns_nstdsums.cpp @@ -1577,7 +1577,17 @@ static ex Li_eval(const ex& m_, const ex& x_) } } if (is_zeta) { - return zeta(m_,x_); + lst newx; + for (lst::const_iterator itx = x.begin(); itx != x.end(); ++itx) { + GINAC_ASSERT((*itx == _ex1) || (*itx == _ex_1)); + // XXX: 1 + 0.0*I is considered equal to 1. However + // the former is a not automatically converted + // to a real number. Do the conversion explicitly + // to avoid the "numeric::operator>(): complex inequality" + // exception (and similar problems). + newx.append(*itx != _ex_1 ? _ex1 : _ex_1); + } + return zeta(m_, newx); } if (is_H) { ex prefactor; @@ -2494,7 +2504,12 @@ lst convert_parameter_Li_to_H(const lst& m, const lst& x, ex& pf) res.append(*itm); itm++; while (itx != x.end()) { - signum *= (*itx > 0) ? 1 : -1; + GINAC_ASSERT((*itx == _ex1) || (*itx == _ex_1)); + // XXX: 1 + 0.0*I is considered equal to 1. However the former + // is not automatically converted to a real number. + // Do the conversion explicitly to avoid the + // "numeric::operator>(): complex inequality" exception. + signum *= (*itx != _ex_1) ? 1 : -1; pf *= signum; res.append((*itm) * signum); itm++; -- 2.44.0