]> www.ginac.de Git - ginac.git/blobdiff - ginac/clifford.cpp
* Change section about Square-free decomposition reflecting the recent
[ginac.git] / ginac / clifford.cpp
index bee4618dba6ad2f03fcf74b7013faf5326bbe169..b8083e8d9e8723c7d7129c872d301703044b12e5 100644 (file)
@@ -20,6 +20,9 @@
  *  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)
@@ -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<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;
 }
 
@@ -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<clifford>(other));
        const clifford &o = static_cast<const clifford &>(other);
 
        if (representation_label != o.representation_label) {
@@ -142,7 +136,7 @@ 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<clifford>(other));
        const clifford &o = static_cast<const clifford &>(other);
 
        return representation_label == o.representation_label;
@@ -184,7 +178,7 @@ 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();
+               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());
@@ -214,7 +208,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
                } else if (other - self == 2
                        && is_a<clifford>(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<clifford>(self[2])
                        && is_a<clifford>(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;
                }
        }
@@ -462,12 +456,12 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
                 && is_a<diracone>(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<e.nops(); i++) {
                        const ex &o = e.op(i);
                        if (is_clifford_tinfo(o.return_type_tinfo(), rl))
@@ -480,7 +474,7 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
        } else if (is_ex_exactly_of_type(e, ncmul)) {
 
                if (!is_clifford_tinfo(e.return_type_tinfo(), rl))
-                       return _ex0();
+                       return _ex0;
 
                // Expand product, if necessary
                ex e_expanded = e.expand();
@@ -496,7 +490,7 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
                        // Trace of gamma5 * odd number of gammas and trace of
                        // gamma5 * gamma.mu * gamma.nu are zero
                        if ((num & 1) == 0 || num == 3)
-                               return _ex0();
+                               return _ex0;
 
                        // Tr gamma5 gamma.mu gamma.nu gamma.rho gamma.sigma = 4I * epsilon(mu, nu, rho, sigma)
                        if (num == 5) {
@@ -547,7 +541,7 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
 
                        // Trace of odd number of gammas is zero
                        if ((num & 1) == 1)
-                               return _ex0();
+                               return _ex0;
 
                        // Tr gamma.mu gamma.nu = 4 g.mu.nu
                        if (num == 2) {
@@ -571,7 +565,7 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
                return e.map(fcn);
 
        } else
-               return _ex0();
+               return _ex0;
 }
 
 ex canonicalize_clifford(const ex & e)
@@ -613,7 +607,7 @@ ex canonicalize_clifford(const ex & e)
                                        base_and_index(it[0], b1, i1);
                                        base_and_index(it[1], b2, i2);
                                        it[0] = (lorentz_g(i1, i2) * b1 * b2).simplify_indexed();
-                                       it[1] = _ex2();
+                                       it[1] = _ex2;
                                        ex sum = ncmul(v);
                                        it[0] = save1;
                                        it[1] = save0;