From 5a7178a44f067581d3acd8cff8c0801354d0c61f Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Tue, 24 Apr 2001 17:22:09 +0000 Subject: [PATCH] - added get_representation_label() - clifford contractions honor repr. label - first implementation of dirac_trace(), works with 0..3 clifford objects --- ginac/clifford.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++--- ginac/clifford.h | 10 ++++++ ginac/color.h | 4 +++ 3 files changed, 91 insertions(+), 5 deletions(-) diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 06d9e541..eb1629d4 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -145,9 +145,10 @@ DEFAULT_PRINT(diracgamma5, "gamma5") /** Contraction of a gamma matrix with something else. */ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const { - GINAC_ASSERT(is_ex_of_type(*self, indexed)); + GINAC_ASSERT(is_ex_of_type(*self, clifford)); GINAC_ASSERT(is_ex_of_type(*other, indexed)); GINAC_ASSERT(is_ex_of_type(self->op(0), diracgamma)); + unsigned char rl = ex_to_clifford(*self).get_representation_label(); if (is_ex_of_type(other->op(0), diracgamma)) { @@ -156,7 +157,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other // gamma~mu*gamma.mu = dim*ONE if (other - self == 1) { *self = dim; - *other = dirac_ONE(); + *other = dirac_ONE(rl); return true; // gamma~mu*gamma~alpha*gamma.mu = (2-dim)*gamma~alpha @@ -170,7 +171,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other } else if (other - self == 3 && is_ex_of_type(self[1], clifford) && is_ex_of_type(self[2], clifford)) { - *self = 4 * metric_tensor(self[1].op(1), self[2].op(1)) * dirac_ONE() + (dim - 4) * self[1] * self[2]; + *self = 4 * metric_tensor(self[1].op(1), self[2].op(1)) * dirac_ONE(rl) + (dim - 4) * self[1] * self[2]; self[1] = _ex1(); self[2] = _ex1(); *other = _ex1(); @@ -200,6 +201,7 @@ ex clifford::simplify_ncmul(const exvector & v) const { exvector s; s.reserve(v.size()); + unsigned rl = ex_to_clifford(v[0]).get_representation_label(); // Remove superfluous ONEs exvector::const_iterator cit = v.begin(), citend = v.end(); @@ -251,7 +253,7 @@ ex clifford::simplify_ncmul(const exvector & v) const const ex & ib = b.op(1); if (ia.is_equal(ib)) { a = lorentz_g(ia, ib); - b = dirac_ONE(); + b = dirac_ONE(rl); something_changed = true; } } @@ -260,7 +262,7 @@ ex clifford::simplify_ncmul(const exvector & v) const } if (s.size() == 0) - return clifford(diracone()) * sign; + return clifford(diracone(), rl) * sign; if (something_changed) return nonsimplified_ncmul(s) * sign; else @@ -299,4 +301,74 @@ ex dirac_gamma5(unsigned char rl) return clifford(diracgamma5(), rl); } +ex dirac_trace(const ex & e, unsigned char rl = 0) +{ + if (is_ex_of_type(e, clifford)) { + + if (ex_to_clifford(e).get_representation_label() == rl + && is_ex_of_type(e.op(0), diracone)) + return _ex4(); + else + return _ex0(); + + } else if (is_ex_exactly_of_type(e, add)) { + + // Trace of sum = sum of traces + ex sum = _ex0(); + for (unsigned i=0; i