* Implementation of GiNaC's products of expressions. */
/*
- * GiNaC Copyright (C) 1999-2007 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2008 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
epvector::const_iterator i = seq.begin(), end = seq.end();
while (i != end) {
if (ex_to<numeric>(i->coeff).is_integer())
- deg_sum += i->rest.degree(s) * ex_to<numeric>(i->coeff).to_int();
+ deg_sum += recombine_pair_to_ex(*i).degree(s);
++i;
}
return deg_sum;
epvector::const_iterator i = seq.begin(), end = seq.end();
while (i != end) {
if (ex_to<numeric>(i->coeff).is_integer())
- deg_sum += i->rest.ldegree(s) * ex_to<numeric>(i->coeff).to_int();
+ deg_sum += recombine_pair_to_ex(*i).ldegree(s);
++i;
}
return deg_sum;
// XXX: What is the best way to check if the polynomial is a primitive?
numeric c = i->rest.integer_content();
- const numeric& lead_coeff =
- ex_to<numeric>(ex_to<add>(i->rest).seq.begin()->coeff).div_dyn(c);
+ const numeric lead_coeff =
+ ex_to<numeric>(ex_to<add>(i->rest).seq.begin()->coeff).div(c);
const bool canonicalizable = lead_coeff.is_integer();
// XXX: The main variable is chosen in a random way, so this code
ex mul::expand(unsigned options) const
{
{
- // trivial case: expanding the monomial (~ 30% of all calls)
+ // trivial case: expanding the monomial (~ 30% of all calls)
epvector::const_iterator i = seq.begin(), seq_end = seq.end();
while ((i != seq.end()) && is_a<symbol>(i->rest) && i->coeff.info(info_flags::integer))
++i;
- if (i == seq_end)
- return (new mul(*this))->setflag(status_flags::dynallocated | status_flags::expanded);
+ if (i == seq_end) {
+ setflag(status_flags::expanded);
+ return *this;
+ }
}
// do not rename indices if the object has no indices at all