]> www.ginac.de Git - ginac.git/blobdiff - ginac/clifford.cpp
clifford: fix a few GCCisms (or, not).
[ginac.git] / ginac / clifford.cpp
index d3667aac3f16eeb21169ab3913564137ace9aed9..e5ebb4016ebc6958fc4a291eaf861962fcccfa6b 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */
 
 /*
- *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2010 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,8 +20,6 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <stdexcept>
-
 #include "clifford.h"
 
 #include "ex.h"
@@ -40,6 +38,8 @@
 #include "archive.h"
 #include "utils.h"
 
+#include <stdexcept>
+
 namespace GiNaC {
 
 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(clifford, indexed,
@@ -122,8 +122,9 @@ return_type_t clifford::return_type_tinfo() const
 // archiving
 //////////
 
-clifford::clifford(const archive_node & n, lst & sym_lst) : inherited(n, sym_lst)
+void clifford::read_archive(const archive_node& n, lst& sym_lst)
 {
+       inherited::read_archive(n, sym_lst);
        unsigned rl;
        n.find_unsigned("label", rl);
        representation_label = rl;
@@ -140,13 +141,12 @@ void clifford::archive(archive_node & n) const
        n.add_unsigned("commutator_sign+1", commutator_sign+1);
 }
 
-DEFAULT_UNARCHIVE(clifford)
-DEFAULT_ARCHIVING(diracone)
-DEFAULT_ARCHIVING(cliffordunit)
-DEFAULT_ARCHIVING(diracgamma)
-DEFAULT_ARCHIVING(diracgamma5)
-DEFAULT_ARCHIVING(diracgammaL)
-DEFAULT_ARCHIVING(diracgammaR)
+GINAC_BIND_UNARCHIVER(clifford);
+GINAC_BIND_UNARCHIVER(diracone);
+GINAC_BIND_UNARCHIVER(diracgamma);
+GINAC_BIND_UNARCHIVER(diracgamma5);
+GINAC_BIND_UNARCHIVER(diracgammaL);
+GINAC_BIND_UNARCHIVER(diracgammaR);
 
 
 ex clifford::get_metric(const ex & i, const ex & j, bool symmetrised) const
@@ -1224,22 +1224,27 @@ static ex get_clifford_comp(const ex & e, const ex & c)
        else if (is_a<ncmul>(e) || is_a<mul>(e)) {
                // find a Clifford unit with the same metric, delete it and substitute its index
                size_t ind = e.nops() + 1;
-               for (size_t j = 0; j < e.nops(); j++) 
-                       if (is_a<clifford>(e.op(j)) && ex_to<clifford>(c).same_metric(e.op(j)))
-                               if (ind > e.nops()) 
+               for (size_t j = 0; j < e.nops(); j++) {
+                       if (is_a<clifford>(e.op(j)) && ex_to<clifford>(c).same_metric(e.op(j))) {
+                               if (ind > e.nops()) {
                                        ind = j;
-                               else 
+                               }
+                               else {
                                        throw(std::invalid_argument("get_clifford_comp(): expression is a Clifford multi-vector"));
+                               }
+                       }
+               }
                if (ind < e.nops()) {
                        ex S = 1;
                        bool same_value_index, found_dummy;
                        same_value_index = ( ex_to<idx>(e.op(ind).op(1)).is_numeric()
                                                                 &&  (ival == ex_to<numeric>(ex_to<idx>(e.op(ind).op(1)).get_value()).to_int()) );
                        found_dummy = same_value_index;
-                       for(size_t j=0; j < e.nops(); j++)
-                               if (j != ind) 
-                                       if (same_value_index) 
+                       for (size_t j=0; j < e.nops(); j++) {
+                               if (j != ind) {
+                                       if (same_value_index) {
                                                S = S * e.op(j);
+                                       }
                                        else {
                                                exvector ind_vec = ex_to<indexed>(e.op(j)).get_dummy_indices(ex_to<indexed>(e.op(ind)));
                                                if (ind_vec.size() > 0) {
@@ -1257,6 +1262,8 @@ static ex get_clifford_comp(const ex & e, const ex & c)
                                                } else
                                                        S = S * e.op(j);
                                        }
+                               }
+                       }
                        return (found_dummy ? S : 0);
                } else
                        throw(std::invalid_argument("get_clifford_comp(): expression is not a Clifford vector to the given units"));
@@ -1284,11 +1291,11 @@ lst clifford_to_lst(const ex & e, const ex & c, bool algebraic)
        if (algebraic) // check if algebraic method is applicable
                for (unsigned int i = 0; i < D; i++) 
                        if (pow(c.subs(mu == i, subs_options::no_pattern), 2).is_zero() 
-                               or (not is_a<numeric>(pow(c.subs(mu == i, subs_options::no_pattern), 2))))
+                               || (! is_a<numeric>(pow(c.subs(mu == i, subs_options::no_pattern), 2))))
                                algebraic = false;
        lst V; 
        ex v0 = remove_dirac_ONE(canonicalize_clifford(e+clifford_prime(e)).normal())/2;
-       if (not v0.is_zero())
+       if (! v0.is_zero())
                V.append(v0);
        ex e1 = canonicalize_clifford(e - v0 * dirac_ONE(ex_to<clifford>(c).get_representation_label())); 
        if (algebraic) {
@@ -1305,7 +1312,7 @@ lst clifford_to_lst(const ex & e, const ex & c, bool algebraic)
                        e1 = canonicalize_clifford(expand_dummy_sum(e, true));
                        V.remove_all();
                        v0 = remove_dirac_ONE(canonicalize_clifford(e1+clifford_prime(e1)).normal())/2;
-                       if (not v0.is_zero()) {
+                       if (! v0.is_zero()) {
                                V.append(v0);
                                e1 = canonicalize_clifford(e1 - v0 * dirac_ONE(ex_to<clifford>(c).get_representation_label())); 
                        }