From 01500aefe13a837367c6540ffdc1953332035790 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 43add280..b70e0010 100644 --- a/ginac/inifcns_nstdsums.cpp +++ b/ginac/inifcns_nstdsums.cpp @@ -1201,7 +1201,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()); @@ -1237,7 +1242,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()); @@ -1290,10 +1300,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) { @@ -1337,10 +1358,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.49.0