* Implementation of GiNaC's indexed expressions. */
/*
- * GiNaC Copyright (C) 1999-2014 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2015 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
}
// In the case where a dummy symbol occurs twice in the same indexed object
- // we try all posibilities of raising/lowering and keep the least one in
+ // we try all possibilities of raising/lowering and keep the least one in
// the sense of ex_is_less.
ex optimal_e = e;
size_t numpossibs = 1 << local_var_dummies.size();
// Non-commutative products are always re-expanded to give
// eval_ncmul() the chance to re-order and canonicalize
// the product
+ bool is_a_product = (is_exactly_a<mul>(*it1) || is_exactly_a<ncmul>(*it1)) &&
+ (is_exactly_a<mul>(*it2) || is_exactly_a<ncmul>(*it2));
ex r = (non_commutative ? ex(ncmul(v, true)) : ex(mul(v)));
- return simplify_indexed(r, free_indices, dummy_indices, sp);
+
+ // If new expression is a product we can call this function again,
+ // otherwise we need to pass argument to simplify_indexed() to be expanded
+ if (is_a_product)
+ return simplify_indexed_product(r, free_indices, dummy_indices, sp);
+ else
+ return simplify_indexed(r, free_indices, dummy_indices, sp);
}
// Both objects may have new indices now or they might
terminfo(const ex & orig_, const ex & symm_) : orig(orig_), symm(symm_) {}
ex orig; /**< original term */
- ex symm; /**< symmtrized term */
+ ex symm; /**< symmetrized term */
};
class terminfo_is_less {