ex add::expand(unsigned options) const
{
- if (flags & status_flags::expanded)
+ if (options == 0 && (flags & status_flags::expanded))
return *this;
epvector *vp = expandchildren(options);
if (vp == NULL) {
// the terms have not changed, so it is safe to declare this expanded
- return this->setflag(status_flags::expanded);
+ return (options == 0) ? setflag(status_flags::expanded) : *this;
}
- return (new add(vp, overall_coeff))->setflag(status_flags::expanded | status_flags::dynallocated);
+ return (new add(vp, overall_coeff))->setflag(status_flags::dynallocated | (options == 0 ? status_flags::expanded : 0));
}
} // namespace GiNaC