X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fadd.cpp;h=9110491e3246a7fc750f96fce18bdb3895e7fc24;hp=241516e07283b7e49a3a7fd7bf47490bebb1c9f9;hb=c532971f9e99886781437912ae1655719284ac2f;hpb=e08cda1854bdb82f6706ec269233577690ae00e4 diff --git a/ginac/add.cpp b/ginac/add.cpp index 241516e0..9110491e 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's sums of expressions. */ /* - * GiNaC Copyright (C) 1999-2010 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2015 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 @@ -260,6 +260,16 @@ bool add::info(unsigned inf) const return inherited::info(inf); } +bool add::is_polynomial(const ex & var) const +{ + for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) { + if (!(i->rest).is_polynomial(var)) { + return false; + } + } + return true; +} + int add::degree(const ex & s) const { int deg = std::numeric_limits::min(); @@ -298,7 +308,7 @@ ex add::coeff(const ex & s, int n) const { std::auto_ptr coeffseq(new epvector); std::auto_ptr coeffseq_cliff(new epvector); - char rl = clifford_max_label(s); + int rl = clifford_max_label(s); bool do_clifford = (rl != -1); bool nonscalar = false; @@ -306,14 +316,14 @@ ex add::coeff(const ex & s, int n) const epvector::const_iterator i = seq.begin(), end = seq.end(); while (i != end) { ex restcoeff = i->rest.coeff(s, n); - if (!restcoeff.is_zero()) { - if (do_clifford) { - if (clifford_max_label(restcoeff) == -1) { - coeffseq_cliff->push_back(combine_ex_with_coeff_to_pair(ncmul(restcoeff, dirac_ONE(rl)), i->coeff)); + if (!restcoeff.is_zero()) { + if (do_clifford) { + if (clifford_max_label(restcoeff) == -1) { + coeffseq_cliff->push_back(combine_ex_with_coeff_to_pair(ncmul(restcoeff, dirac_ONE(rl)), i->coeff)); } else { - coeffseq_cliff->push_back(combine_ex_with_coeff_to_pair(restcoeff, i->coeff)); + coeffseq_cliff->push_back(combine_ex_with_coeff_to_pair(restcoeff, i->coeff)); nonscalar = true; - } + } } coeffseq->push_back(combine_ex_with_coeff_to_pair(restcoeff, i->coeff)); } @@ -565,7 +575,7 @@ expair add::split_ex_to_pair(const ex & e) const } expair add::combine_ex_with_coeff_to_pair(const ex & e, - const ex & c) const + const ex & c) const { GINAC_ASSERT(is_exactly_a(c)); if (is_exactly_a(e)) { @@ -591,7 +601,7 @@ expair add::combine_ex_with_coeff_to_pair(const ex & e, } expair add::combine_pair_with_coeff_to_pair(const expair & p, - const ex & c) const + const ex & c) const { GINAC_ASSERT(is_exactly_a(p.coeff)); GINAC_ASSERT(is_exactly_a(c)); @@ -603,7 +613,7 @@ expair add::combine_pair_with_coeff_to_pair(const expair & p, return expair(p.rest,ex_to(p.coeff).mul_dyn(ex_to(c))); } - + ex add::recombine_pair_to_ex(const expair & p) const { if (ex_to(p.coeff).is_equal(*_num1_p))