X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fclifford.cpp;h=b8083e8d9e8723c7d7129c872d301703044b12e5;hp=8687f969777cbd11837aa181e2a69ab4229657c4;hb=bb3808bb989db7e81755f1bfc7c6863d7c960e06;hpb=834bacb25c9427fb03b8f9b34605738fb59202e1 diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 8687f969..b8083e8d 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -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; @@ -129,7 +123,7 @@ DEFAULT_ARCHIVING(diracgamma5) int clifford::compare_same_type(const basic & other) const { - GINAC_ASSERT(is_of_type(other, clifford)); + GINAC_ASSERT(is_a(other)); const clifford &o = static_cast(other); if (representation_label != o.representation_label) { @@ -142,13 +136,13 @@ int clifford::compare_same_type(const basic & other) const bool clifford::match_same_type(const basic & other) const { - GINAC_ASSERT(is_of_type(other, clifford)); + GINAC_ASSERT(is_a(other)); const clifford &o = static_cast(other); return representation_label == o.representation_label; } -void clifford::print(const print_context & c, unsigned level = 0) const +void clifford::print(const print_context & c, unsigned level) const { if (!is_a(seq[0]) && !is_a(seq[0]) && !is_a(seq[0])) { @@ -184,7 +178,7 @@ 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(); + 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()); @@ -214,7 +208,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other } else if (other - self == 2 && is_a(self[1])) { *self = 2 - dim; - *other = _ex1(); + *other = _ex1; return true; // gamma~mu gamma~alpha gamma~beta gamma.mu = 4 g~alpha~beta + (dim-4) gamam~alpha gamma~beta @@ -225,9 +219,9 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other base_and_index(self[1], b1, i1); base_and_index(self[2], b2, i2); *self = 4 * lorentz_g(i1, i2) * b1 * b2 * dirac_ONE(rl) + (dim - 4) * self[1] * self[2]; - self[1] = _ex1(); - self[2] = _ex1(); - *other = _ex1(); + self[1] = _ex1; + self[2] = _ex1; + *other = _ex1; return true; // gamma~mu gamma~alpha gamma~beta gamma~delta gamma.mu = -2 gamma~delta gamma~beta gamma~alpha - (dim-4) gamam~alpha gamma~beta gamma~delta @@ -236,10 +230,10 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other && is_a(self[2]) && is_a(self[3])) { *self = -2 * self[3] * self[2] * self[1] - (dim - 4) * self[1] * self[2] * self[3]; - self[1] = _ex1(); - self[2] = _ex1(); - self[3] = _ex1(); - *other = _ex1(); + self[1] = _ex1; + self[2] = _ex1; + self[3] = _ex1; + *other = _ex1; return true; // gamma~mu S gamma~alpha gamma.mu = 2 gamma~alpha S - gamma~mu S gamma.mu gamma~alpha @@ -254,15 +248,15 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other } it = self + 1; - ex S = _ex1(); + ex S = _ex1; while (it != next_to_last) { S *= *it; - *it++ = _ex1(); + *it++ = _ex1; } *self = 2 * (*next_to_last) * S - (*self) * S * (*other) * (*next_to_last); - *next_to_last = _ex1(); - *other = _ex1(); + *next_to_last = _ex1; + *other = _ex1; return true; } } @@ -281,7 +275,7 @@ ex clifford::simplify_ncmul(const exvector & v) const // Remove superfluous ONEs exvector::const_iterator cit = v.begin(), citend = v.end(); while (cit != citend) { - if (!is_a(cit->op(0))) + if (!is_a(*cit) || !is_a(cit->op(0))) s.push_back(*cit); cit++; } @@ -296,7 +290,7 @@ ex clifford::simplify_ncmul(const exvector & v) const exvector::iterator it = next_to_last; while (true) { exvector::iterator it2 = it + 1; - if (!is_a(it->op(0)) && is_a(it2->op(0))) { + if (is_a(*it) && is_a(*it2) && !is_a(it->op(0)) && is_a(it2->op(0))) { it->swap(*it2); sign = -sign; something_changed = true; @@ -312,17 +306,19 @@ ex clifford::simplify_ncmul(const exvector & v) const } // Remove squares of gamma5 - while (s.size() >= 2 && is_a(s[0].op(0)) && is_a(s[1].op(0))) { + 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 = s.begin(), itend = s.end() - 1; - while (it != itend) { + exvector::iterator it, itend = s.end() - 1; + for (it = s.begin(); it != itend; ++it) { ex & a = it[0]; ex & b = it[1]; + if (!is_a(a) || !is_a(b)) + continue; if (is_a(a.op(0)) && is_a(b.op(0))) { const ex & ia = a.op(1); const ex & ib = b.op(1); @@ -341,7 +337,6 @@ ex clifford::simplify_ncmul(const exvector & v) const something_changed = true; } } - ++it; } } @@ -461,12 +456,12 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE) && is_a(e.op(0))) return trONE; else - return _ex0(); + return _ex0; } else if (is_ex_exactly_of_type(e, mul)) { // Trace of product: pull out non-clifford factors - ex prod = _ex1(); + ex prod = _ex1; for (unsigned i=0; i