]> www.ginac.de Git - ginac.git/commitdiff
added an additional dummy index symmetrization run over sums in
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Sat, 25 May 2002 18:39:43 +0000 (18:39 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Sat, 25 May 2002 18:39:43 +0000 (18:39 +0000)
simplify_indexed(), to find possible cancellations

check/exam_indexed.cpp
ginac/indexed.cpp

index a8c7cbd698f6da73a6673bb32e60cdfd44c387c9..4d09bdff625303e7badfb2427b9c2dc30e8ee312 100644 (file)
@@ -155,7 +155,7 @@ static unsigned symmetry_check(void)
        unsigned result = 0;
 
        idx i(symbol("i"), 3), j(symbol("j"), 3), k(symbol("k"), 3), l(symbol("l"), 3);
-       symbol A("A"), B("B");
+       symbol A("A"), B("B"), C("C");
        ex e;
 
        result += check_equal(indexed(A, sy_symm(), i, j), indexed(A, sy_symm(), j, i));
@@ -187,6 +187,9 @@ static unsigned symmetry_check(void)
        result += check_equal(symmetrize(e), 0);
        result += check_equal(antisymmetrize(e), e);
 
+       e = (indexed(A, sy_anti(), i, j, k, l) * (indexed(B, j) * indexed(C, k) + indexed(B, k) * indexed(C, j)) + indexed(B, i, l)).expand();
+       result += check_equal_simplify(e, indexed(B, i, l));
+
        return result;
 }
 
index dcd6d9510d6d0ac688802373f30f7d93e0f07362..dca12fd8945344c1c826e469aaa739dfa94631de 100644 (file)
@@ -870,6 +870,27 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi
                        }
                }
 
+               if (sum.is_zero()) {
+                       free_indices.clear();
+                       return sum;
+               }
+
+               // Symmetrizing over the dummy indices may cancel terms
+               int num_terms_orig = (is_a<add>(sum) ? sum.nops() : 1);
+               if (num_terms_orig > 1 && dummy_indices.size() >= 2) {
+                       lst dummy_syms;
+                       for (int i=0; i<dummy_indices.size(); i++)
+                               dummy_syms.append(dummy_indices[i].op(0));
+                       ex sum_symm = sum.symmetrize(dummy_syms);
+                       if (sum_symm.is_zero()) {
+                               free_indices.clear();
+                               return _ex0;
+                       }
+                       int num_terms = (is_a<add>(sum_symm) ? sum_symm.nops() : 1);
+                       if (num_terms < num_terms_orig)
+                               return sum_symm;
+               }
+
                return sum;
        }