]> www.ginac.de Git - ginac.git/blobdiff - ginac/clifford.cpp
clifford and color objects are not contracted if their representation labels
[ginac.git] / ginac / clifford.cpp
index b8083e8d9e8723c7d7129c872d301703044b12e5..86678ecc6f342e881b3074c524258160287b8917 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */
 
 /*
- *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2002 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
@@ -179,6 +179,9 @@ static void base_and_index(const ex & c, ex & b, ex & i)
        if (is_a<diracgamma>(c.op(0))) { // proper dirac gamma object
                i = c.op(1);
                b = _ex1;
+       } else if (is_a<diracgamma5>(c.op(0))) { // gamma5
+               i = _ex0;
+               b = _ex1;
        } else { // slash object, generate new dummy index
                varidx ix((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(c.op(1)).get_dim());
                b = indexed(c.op(0), ix.toggle_variance());
@@ -196,6 +199,10 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
 
        if (is_a<clifford>(*other)) {
 
+               // Contraction only makes sense if the represenation labels are equal
+               if (ex_to<clifford>(*other).get_representation_label() != rl)
+                       return false;
+
                ex dim = ex_to<idx>(self->op(1)).get_dim();
 
                // gamma~mu gamma.mu = dim ONE
@@ -305,12 +312,6 @@ ex clifford::simplify_ncmul(const exvector & v) const
                }
        }
 
-       // Remove squares of gamma5
-       while (s.size() >= 2 && is_a<clifford>(s[0]) && is_a<clifford>(s[1]) && is_a<diracgamma5>(s[0].op(0)) && is_a<diracgamma5>(s[1].op(0))) {
-               s.erase(s.begin(), s.begin() + 2);
-               something_changed = true;
-       }
-
        // Remove equal adjacent gammas
        if (s.size() >= 2) {
                exvector::iterator it, itend = s.end() - 1;
@@ -319,7 +320,9 @@ ex clifford::simplify_ncmul(const exvector & v) const
                        ex & b = it[1];
                        if (!is_a<clifford>(a) || !is_a<clifford>(b))
                                continue;
-                       if (is_a<diracgamma>(a.op(0)) && is_a<diracgamma>(b.op(0))) {
+                       bool a_is_diracgamma = is_a<diracgamma>(a.op(0));
+                       bool b_is_diracgamma = is_a<diracgamma>(b.op(0));
+                       if (a_is_diracgamma && b_is_diracgamma) {
                                const ex & ia = a.op(1);
                                const ex & ib = b.op(1);
                                if (ia.is_equal(ib)) { // gamma~alpha gamma~alpha -> g~alpha~alpha
@@ -327,7 +330,12 @@ ex clifford::simplify_ncmul(const exvector & v) const
                                        b = dirac_ONE(representation_label);
                                        something_changed = true;
                                }
-                       } else if (!is_a<diracgamma>(a.op(0)) && !is_a<diracgamma>(b.op(0))) {
+                       } else if (is_a<diracgamma5>(a.op(0)) && is_a<diracgamma5>(b.op(0))) {
+                               // Remove squares of gamma5
+                               a = dirac_ONE(representation_label);
+                               b = dirac_ONE(representation_label);
+                               something_changed = true;
+                       } else if (!a_is_diracgamma && !b_is_diracgamma) {
                                const ex & ba = a.op(0);
                                const ex & bb = b.op(0);
                                if (ba.is_equal(bb)) { // a\ a\ -> a^2