public:
enum {
expand_indexed = 0x0001, ///< expands (a+b).i to a.i+b.i
- expand_function_args = 0x0002 ///< expands the arguments of functions
+ expand_function_args = 0x0002, ///< expands the arguments of functions
+ expand_rename_idx = 0x0004 ///< used internally by mul::expand()
};
};
return (new mul(*this))->setflag(status_flags::dynallocated | status_flags::expanded);
}
- const bool skip_idx_rename = ! info(info_flags::has_indices);
- if (skip_idx_rename)
- ++(mul_expand_stats::n_indexless);
+ // 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);
return _ex1;
}
+ // do not bother to rename indices if there are no any.
+ if ((!(options & expand_options::expand_rename_idx))
+ && m.info(info_flags::has_indices))
+ options |= expand_options::expand_rename_idx;
// Leave it to multiplication since dummy indices have to be renamed
- if (m.info(info_flags::has_indices) && (get_all_dummy_indices(m).size() > 0) && n.is_positive()) {
+ if ((!(options & expand_options::expand_rename_idx)) &&
+ (get_all_dummy_indices(m).size() > 0) && n.is_positive()) {
ex result = m;
for (int i=1; i < n.to_int(); i++)
result *= rename_dummy_indices_uniquely(m,m);