From f30ea8e711499ac166c4cd54357a4bc6f5e7264c Mon Sep 17 00:00:00 2001 From: Jens Vollinga Date: Mon, 29 Mar 2010 00:21:18 +0200 Subject: [PATCH 1/1] Products (class mul) now answer correctly to info_flags::negative and info_flags::negint. (cherry picked from commit 8a30acc990818792ec4e8f8f4d48f5dd8286dbed) --- ginac/mul.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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); } -- 2.44.0