X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fpolynomial%2Fcollect_vargs.cpp;h=259326873bf1da4fd6866a8d2267ec0a13665264;hp=f014a874e4a76cda43de60f49d1530226efdfb5e;hb=c13d5e0ed2ce6223bc6c4340bb00daf2e24ea923;hpb=80b1c3e0ee0e465d56e5c76bef4e52ef2dbc5197 diff --git a/ginac/polynomial/collect_vargs.cpp b/ginac/polynomial/collect_vargs.cpp index f014a874..25932687 100644 --- a/ginac/polynomial/collect_vargs.cpp +++ b/ginac/polynomial/collect_vargs.cpp @@ -1,19 +1,41 @@ -#include -#include -#include -#include -#include +/** @file collect_vargs.cpp + * + * Utility functions. */ + +/* + * GiNaC Copyright (C) 1999-2010 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + #include "add.h" #include "mul.h" #include "operators.h" #include "power.h" #include "collect_vargs.h" -#include #include "smod_helpers.h" #include "debug.h" -namespace GiNaC -{ +#include +#include +#include +#include +#include +#include + +namespace GiNaC { typedef std::map ex_collect_priv_t; @@ -126,8 +148,14 @@ ex_collect_to_ex(const ex_collect_t& ec, const GiNaC::exvector& vars) exvector tv; tv.reserve(vars.size() + 1); for (std::size_t j = 0; j < vars.size(); ++j) { - if (ec[i].first[j] != 0) - tv.push_back(power(vars[j], ec[i].first[j])); + const exp_vector_t& exp_vector(ec[i].first); + + bug_on(exp_vector.size() != vars.size(), + "expected " << vars.size() << " variables, " + "expression has " << exp_vector.size() << " instead"); + + if (exp_vector[j] != 0) + tv.push_back(power(vars[j], exp_vector[j])); } tv.push_back(ec[i].second); ex tmp = (new mul(tv))->setflag(status_flags::dynallocated); @@ -164,4 +192,3 @@ cln::cl_I integer_lcoeff(const ex& e, const exvector& vars) } } // namespace GiNaC -