From dacdde924c6d2e43ec52c2d6310d208d8e4024f6 Mon Sep 17 00:00:00 2001 From: Jens Vollinga Date: Mon, 8 Sep 2008 18:17:51 +0200 Subject: [PATCH] Fixed bug. G() ignored the imaginary parts of the arguments. --- ginac/inifcns_nstdsums.cpp | 52 ++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/ginac/inifcns_nstdsums.cpp b/ginac/inifcns_nstdsums.cpp index dd8625a9..bf5ce093 100644 --- a/ginac/inifcns_nstdsums.cpp +++ b/ginac/inifcns_nstdsums.cpp @@ -1219,7 +1219,12 @@ static ex G2_evalf(const ex& x_, const ex& y) if (*it != _ex0) { all_zero = false; } - s.append(+1); + if ( !ex_to(*it).is_real() && ex_to(*it).imag() < 0 ) { + s.append(-1); + } + else { + s.append(+1); + } } if (all_zero) { return pow(log(y), x.nops()) / factorial(x.nops()); @@ -1255,7 +1260,12 @@ static ex G2_eval(const ex& x_, const ex& y) if (*it != _ex0) { all_zero = false; } - s.append(+1); + if ( !ex_to(*it).is_real() && ex_to(*it).imag() < 0 ) { + s.append(-1); + } + else { + s.append(+1); + } } if (all_zero) { return pow(log(y), x.nops()) / factorial(x.nops()); @@ -1308,10 +1318,21 @@ static ex G3_evalf(const ex& x_, const ex& s_, const ex& y) if (*itx != _ex0) { all_zero = false; } - if (*its >= 0) { - sn.append(+1); - } else { - sn.append(-1); + if ( ex_to(*itx).is_real() ) { + if ( *its >= 0 ) { + sn.append(+1); + } + else { + sn.append(-1); + } + } + else { + if ( ex_to(*itx).imag() > 0 ) { + sn.append(+1); + } + else { + sn.append(-1); + } } } if (all_zero) { @@ -1355,10 +1376,21 @@ static ex G3_eval(const ex& x_, const ex& s_, const ex& y) if (*itx != _ex0) { all_zero = false; } - if (*its >= 0) { - sn.append(+1); - } else { - sn.append(-1); + if ( ex_to(*itx).is_real() ) { + if ( *its >= 0 ) { + sn.append(+1); + } + else { + sn.append(-1); + } + } + else { + if ( ex_to(*itx).imag() > 0 ) { + sn.append(+1); + } + else { + sn.append(-1); + } } } if (all_zero) { -- 2.44.0