From: Stefan Weinzierl Date: Tue, 28 Jan 2014 06:58:06 +0000 (+0200) Subject: Li_eval(): avoid the "numeric::operator>(): complex inequality" exception. X-Git-Tag: release_1-6-3~25 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=commitdiff_plain;h=5acfced77964d811d66f83e83b8fa06d77f3edd0;p=ginac.git 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] --- 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++;