summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7d05f39)
Expanding monomials should be done as fast as possible [Sheplyakov].
#include "lst.h"
#include "archive.h"
#include "utils.h"
#include "lst.h"
#include "archive.h"
#include "utils.h"
#include "compiler.h"
namespace GiNaC {
#include "compiler.h"
namespace GiNaC {
ex mul::expand(unsigned options) const
{
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<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);
+ }
+
const bool skip_idx_rename = ! info(info_flags::has_indices);
// First, expand the children
std::auto_ptr<epvector> expanded_seqp = expandchildren(options);
const bool skip_idx_rename = ! info(info_flags::has_indices);
// First, expand the children
std::auto_ptr<epvector> expanded_seqp = expandchildren(options);
ex power::expand(unsigned options) const
{
ex power::expand(unsigned options) const
{
+ if (is_a<symbol>(basis) && exponent.info(info_flags::integer))
+ return (new power(*this))->setflag(status_flags::dynallocated | status_flags::expanded);
+
if (options == 0 && (flags & status_flags::expanded))
return *this;
if (options == 0 && (flags & status_flags::expanded))
return *this;