X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fadd.cpp;h=b37ab79def6926ca36c3dc804f068580c10b7b09;hp=dd70659e42ce348bb8ca234e82d3bc98437a57ad;hb=18d403808b2c0fd73f43cbf4e346c5902f052a65;hpb=4cf53676d7823ec3c55a90df7723f7f1492a95b2 diff --git a/ginac/add.cpp b/ginac/add.cpp index dd70659e..b37ab79d 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's sums of expressions. */ /* - * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2007 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include #include +#include #include "add.h" #include "mul.h" @@ -258,7 +259,7 @@ bool add::info(unsigned inf) const int add::degree(const ex & s) const { - int deg = INT_MIN; + int deg = std::numeric_limits::min(); if (!overall_coeff.is_zero()) deg = 0; @@ -275,7 +276,7 @@ int add::degree(const ex & s) const int add::ldegree(const ex & s) const { - int deg = INT_MAX; + int deg = std::numeric_limits::max(); if (!overall_coeff.is_zero()) deg = 0; @@ -429,11 +430,14 @@ ex add::real_part() const epvector v; v.reserve(seq.size()); for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) - if ((i->coeff).info(info_flags::real)) - v.push_back(expair((i->rest).real_part(), i->coeff)); - else { + if ((i->coeff).info(info_flags::real)) { + ex rp = (i->rest).real_part(); + if (!rp.is_zero()) + v.push_back(expair(rp, i->coeff)); + } else { ex rp=recombine_pair_to_ex(*i).real_part(); - v.push_back(split_ex_to_pair(rp)); + if (!rp.is_zero()) + v.push_back(split_ex_to_pair(rp)); } return (new add(v, overall_coeff.real_part())) -> setflag(status_flags::dynallocated); @@ -444,11 +448,14 @@ ex add::imag_part() const epvector v; v.reserve(seq.size()); for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) - if ((i->coeff).info(info_flags::real)) - v.push_back(expair((i->rest).imag_part(), i->coeff)); - else { + if ((i->coeff).info(info_flags::real)) { + ex ip = (i->rest).imag_part(); + if (!ip.is_zero()) + v.push_back(expair(ip, i->coeff)); + } else { ex ip=recombine_pair_to_ex(*i).imag_part(); - v.push_back(split_ex_to_pair(ip)); + if (!ip.is_zero()) + v.push_back(split_ex_to_pair(ip)); } return (new add(v, overall_coeff.imag_part())) -> setflag(status_flags::dynallocated);