X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fmul.cpp;h=298715b33fd2eabfd28ea9390229fb3f5b90b39d;hp=db8b9f14acd308d76344ed57bfc44857f63e4d24;hb=da6a61ba2586263e46ade4b67dca121506c2bff9;hpb=7d05f39c095dc51cc4526b17a5ab3280f8924219 diff --git a/ginac/mul.cpp b/ginac/mul.cpp index db8b9f14..298715b3 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -34,6 +34,7 @@ #include "lst.h" #include "archive.h" #include "utils.h" +#include "symbol.h" #include "compiler.h" namespace GiNaC { @@ -992,6 +993,15 @@ bool mul::can_be_further_expanded(const ex & e) ex mul::expand(unsigned options) const { + { + // 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(i->rest) && i->coeff.info(info_flags::integer)) + ++i; + if (i == seq_end) + return (new mul(*this))->setflag(status_flags::dynallocated | status_flags::expanded); + } + const bool skip_idx_rename = ! info(info_flags::has_indices); // First, expand the children std::auto_ptr expanded_seqp = expandchildren(options);