From: Jens Vollinga Date: Sun, 28 Mar 2010 22:21:18 +0000 (+0200) Subject: Products (class mul) now answer correctly to info_flags::negative and X-Git-Tag: release_1-6-0~60 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=8a30acc990818792ec4e8f8f4d48f5dd8286dbed;hp=704fe31c78553ffe2058c72bc4d17e6a1ae31350 Products (class mul) now answer correctly to info_flags::negative and info_flags::negint. --- diff --git a/ginac/mul.cpp b/ginac/mul.cpp index a35e8af9..dfda4100 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -309,6 +309,40 @@ bool mul::info(unsigned inf) const } return false; } + case info_flags::negative: { + bool neg = false; + epvector::const_iterator i = seq.begin(), end = seq.end(); + while (i != end) { + const ex& factor = recombine_pair_to_ex(*i++); + if (factor.info(info_flags::positive)) + continue; + else if (factor.info(info_flags::negative)) + neg = !neg; + else + return false; + } + if (overall_coeff.info(info_flags::negative)) + neg = !neg; + return neg; + } + case info_flags::negint: { + bool neg = false; + epvector::const_iterator i = seq.begin(), end = seq.end(); + while (i != end) { + const ex& factor = recombine_pair_to_ex(*i++); + if (factor.info(info_flags::posint)) + continue; + else if (factor.info(info_flags::negint)) + neg = !neg; + else + return false; + } + if (overall_coeff.info(info_flags::negint)) + neg = !neg; + else if (!overall_coeff.info(info_flags::posint)) + return false; + return neg; + } } return inherited::info(inf); }