]> www.ginac.de Git - ginac.git/blobdiff - ginac/clifford.cpp
Added complex conjugation methods and GiNaC function "conjugate".
[ginac.git] / ginac / clifford.cpp
index ff834bce71f4ab54ee9f689ce2cb9fb1810ffdeb..679def3a737ad5bf003852f940ea5d012f7f9ef5 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */
 
 /*
- *  GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2004 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
@@ -34,7 +34,6 @@
 #include "relational.h"
 #include "operators.h"
 #include "mul.h"
-#include "print.h"
 #include "archive.h"
 #include "utils.h"
 
@@ -105,7 +104,7 @@ clifford::clifford(unsigned char rl, const exvector & v, bool discardable) : inh
        tinfo_key = TINFO_clifford;
 }
 
-clifford::clifford(unsigned char rl, exvector * vp) : inherited(sy_none(), vp), representation_label(rl)
+clifford::clifford(unsigned char rl, std::auto_ptr<exvector> vp) : inherited(sy_none(), vp), representation_label(rl)
 {
        tinfo_key = TINFO_clifford;
 }
@@ -480,11 +479,26 @@ ex clifford::thiscontainer(const exvector & v) const
        return clifford(representation_label, v);
 }
 
-ex clifford::thiscontainer(exvector * vp) const
+ex clifford::thiscontainer(std::auto_ptr<exvector> vp) const
 {
        return clifford(representation_label, vp);
 }
 
+ex diracgamma5::conjugate() const
+{      
+       return _ex_1 * (*this);
+}
+
+ex diracgammaL::conjugate() const
+{
+       return (new diracgammaR)->setflag(status_flags::dynallocated);
+}
+
+ex diracgammaR::conjugate() const
+{
+       return (new diracgammaL)->setflag(status_flags::dynallocated);
+}
+
 //////////
 // global functions
 //////////
@@ -707,13 +721,12 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
 ex canonicalize_clifford(const ex & e)
 {
        // Scan for any ncmul objects
-       lst srl;
+       exmap srl;
        ex aux = e.to_rational(srl);
-       for (size_t i=0; i<srl.nops(); i++) {
+       for (exmap::iterator i = srl.begin(); i != srl.end(); ++i) {
 
-               ex o = srl.op(i);
-               ex lhs = o.lhs();
-               ex rhs = o.rhs();
+               ex lhs = i->first;
+               ex rhs = i->second;
 
                if (is_exactly_a<ncmul>(rhs)
                 && rhs.return_type() == return_types::noncommutative
@@ -722,7 +735,7 @@ ex canonicalize_clifford(const ex & e)
                        // Expand product, if necessary
                        ex rhs_expanded = rhs.expand();
                        if (!is_a<ncmul>(rhs_expanded)) {
-                               srl[i] = (lhs == canonicalize_clifford(rhs_expanded));
+                               i->second = canonicalize_clifford(rhs_expanded);
                                continue;
 
                        } else if (!is_a<clifford>(rhs.op(0)))
@@ -749,7 +762,7 @@ ex canonicalize_clifford(const ex & e)
                                        it[0] = save1;
                                        it[1] = save0;
                                        sum -= ncmul(v, true);
-                                       srl[i] = (lhs == canonicalize_clifford(sum));
+                                       i->second = canonicalize_clifford(sum);
                                        goto next_sym;
                                }
                                ++it;