]> www.ginac.de Git - ginac.git/blobdiff - ginac/indexed.cpp
Fix some apparent typos and misindentations.
[ginac.git] / ginac / indexed.cpp
index e8ca5cec682a03afcb68a558a1c15d00f5932bc2..873a9ad0b9661d721f14d09439ab8256661b7260 100644 (file)
@@ -3,7 +3,7 @@
  *  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
@@ -648,7 +648,7 @@ bool reposition_dummy_indices(ex & e, exvector & variant_dummy_indices, exvector
        }
 
        // 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();
@@ -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<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
@@ -980,7 +988,7 @@ public:
        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 {