* 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
// 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;
+ }
}
- const bool skip_idx_rename = ! info(info_flags::has_indices);
+ // do not rename indices if the object has no indices at all
+ if ((!(options & expand_options::expand_rename_idx)) &&
+ this->info(info_flags::has_indices))
+ options |= expand_options::expand_rename_idx;
+
+ const bool skip_idx_rename = !(options & expand_options::expand_rename_idx);
+
// First, expand the children
std::auto_ptr<epvector> expanded_seqp = expandchildren(options);
const epvector & expanded_seq = (expanded_seqp.get() ? *expanded_seqp : seq);