From: Vladimir V. Kisil Date: Sun, 25 Jan 2015 10:39:04 +0000 (+0100) Subject: Small optimization in simplify_indexed. X-Git-Tag: ginac_1-6-4~13 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=a1232ef3c23d3af7673c96ec4f0e0c652054564a Small optimization in simplify_indexed. If the new expression is product again then we call the same function return simplify_indexed_product() rather than the its mother implify_indexed(). --- diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp index e8ca5cec..0c4103c2 100644 --- a/ginac/indexed.cpp +++ b/ginac/indexed.cpp @@ -874,8 +874,16 @@ contraction_done: // 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(*it1) || is_exactly_a(*it1)) && + (is_exactly_a(*it2) || is_exactly_a(*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