]> www.ginac.de Git - ginac.git/commitdiff
Li_eval(): avoid the "numeric::operator>(): complex inequality" exception.
authorStefan Weinzierl <stefanw@thep.physik.uni-mainz.de>
Tue, 28 Jan 2014 06:58:06 +0000 (08:58 +0200)
committerAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Tue, 28 Jan 2014 07:02:32 +0000 (09:02 +0200)
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

index 9876075c6526fdd4fd6983cc5a37798ca3179eb2..975a81e685ddb18863f4ce6f0625455aef0d36b4 100644 (file)
@@ -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++;