X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fclifford.cpp;h=1b3d034a9c41e6871ebb60aaab6f43de30d70d0e;hp=131a00eea909fa7ffe8988f399f244d1e19ea780;hb=7e7beee2c946694130a484c923f6af8391867495;hpb=27d6204effdef95a00af461fff98024e290dbaa7 diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 131a00ee..1b3d034a 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -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 @@ -20,6 +20,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include + #include "clifford.h" #include "ex.h" #include "idx.h" @@ -32,11 +35,8 @@ #include "mul.h" #include "print.h" #include "archive.h" -#include "debugmsg.h" #include "utils.h" -#include - namespace GiNaC { GINAC_IMPLEMENT_REGISTERED_CLASS(clifford, indexed) @@ -45,12 +45,11 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(diracgamma, tensor) GINAC_IMPLEMENT_REGISTERED_CLASS(diracgamma5, tensor) ////////// -// default constructor, destructor, copy constructor assignment operator and helpers +// default ctor, dtor, copy ctor, assignment operator and helpers ////////// clifford::clifford() : representation_label(0) { - debugmsg("clifford default constructor", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_clifford; } @@ -74,7 +73,6 @@ DEFAULT_CTORS(diracgamma5) * @see dirac_ONE */ clifford::clifford(const ex & b, unsigned char rl) : inherited(b), representation_label(rl) { - debugmsg("clifford constructor from ex", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_clifford; } @@ -83,20 +81,17 @@ clifford::clifford(const ex & b, unsigned char rl) : inherited(b), representatio * @see dirac_gamma */ clifford::clifford(const ex & b, const ex & mu, unsigned char rl) : inherited(b, mu), representation_label(rl) { - debugmsg("clifford constructor from ex,ex", LOGLEVEL_CONSTRUCT); GINAC_ASSERT(is_a(mu)); tinfo_key = TINFO_clifford; } clifford::clifford(unsigned char rl, const exvector & v, bool discardable) : inherited(sy_none(), v, discardable), representation_label(rl) { - debugmsg("clifford constructor from unsigned char,exvector", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_clifford; } clifford::clifford(unsigned char rl, exvector * vp) : inherited(sy_none(), vp), representation_label(rl) { - debugmsg("clifford constructor from unsigned char,exvector *", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_clifford; } @@ -106,7 +101,6 @@ clifford::clifford(unsigned char rl, exvector * vp) : inherited(sy_none(), vp), clifford::clifford(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) { - debugmsg("clifford constructor from archive_node", LOGLEVEL_CONSTRUCT); unsigned rl; n.find_unsigned("label", rl); representation_label = rl; @@ -185,6 +179,9 @@ static void base_and_index(const ex & c, ex & b, ex & i) if (is_a(c.op(0))) { // proper dirac gamma object i = c.op(1); b = _ex1; + } else if (is_a(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(c.op(1)).get_dim()); b = indexed(c.op(0), ix.toggle_variance()); @@ -202,6 +199,10 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other if (is_a(*other)) { + // Contraction only makes sense if the represenation labels are equal + if (ex_to(*other).get_representation_label() != rl) + return false; + ex dim = ex_to(self->op(1)).get_dim(); // gamma~mu gamma.mu = dim ONE @@ -311,12 +312,6 @@ ex clifford::simplify_ncmul(const exvector & v) const } } - // Remove squares of gamma5 - while (s.size() >= 2 && is_a(s[0]) && is_a(s[1]) && is_a(s[0].op(0)) && is_a(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; @@ -325,7 +320,9 @@ ex clifford::simplify_ncmul(const exvector & v) const ex & b = it[1]; if (!is_a(a) || !is_a(b)) continue; - if (is_a(a.op(0)) && is_a(b.op(0))) { + bool a_is_diracgamma = is_a(a.op(0)); + bool b_is_diracgamma = is_a(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 @@ -333,7 +330,12 @@ ex clifford::simplify_ncmul(const exvector & v) const b = dirac_ONE(representation_label); something_changed = true; } - } else if (!is_a(a.op(0)) && !is_a(b.op(0))) { + } else if (is_a(a.op(0)) && is_a(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 @@ -499,17 +501,19 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE) return _ex0; // Tr gamma5 gamma.mu gamma.nu gamma.rho gamma.sigma = 4I * epsilon(mu, nu, rho, sigma) + // (the epsilon is always 4-dimensional) if (num == 5) { ex b1, i1, b2, i2, b3, i3, b4, i4; base_and_index(e.op(1), b1, i1); base_and_index(e.op(2), b2, i2); base_and_index(e.op(3), b3, i3); base_and_index(e.op(4), b4, i4); - return trONE * I * (eps0123(i1, i2, i3, i4) * b1 * b2 * b3 * b4).simplify_indexed(); + return trONE * I * (lorentz_eps(ex_to(i1).replace_dim(_ex4), ex_to(i2).replace_dim(_ex4), ex_to(i3).replace_dim(_ex4), ex_to(i4).replace_dim(_ex4)) * b1 * b2 * b3 * b4).simplify_indexed(); } // Tr gamma5 S_2k = // I/4! * epsilon0123.mu1.mu2.mu3.mu4 * Tr gamma.mu1 gamma.mu2 gamma.mu3 gamma.mu4 S_2k + // (the epsilon is always 4-dimensional) exvector ix(num-1), bv(num-1); for (unsigned i=1; i(idx1).replace_dim(_ex4), ex_to(idx2).replace_dim(_ex4), ex_to(idx3).replace_dim(_ex4), ex_to(idx4).replace_dim(_ex4)) * trace_string(v.begin(), num - 4); } }