* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <iostream>
+#include <stdexcept>
+
#include "clifford.h"
#include "ex.h"
#include "idx.h"
#include "mul.h"
#include "print.h"
#include "archive.h"
-#include "debugmsg.h"
#include "utils.h"
-#include <stdexcept>
-
namespace GiNaC {
GINAC_IMPLEMENT_REGISTERED_CLASS(clifford, indexed)
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;
}
* @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;
}
* @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<varidx>(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;
}
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;
}
}
- // 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;
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
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