]> www.ginac.de Git - ginac.git/blobdiff - ginac/clifford.cpp
Fix some apparent typos and misindentations.
[ginac.git] / ginac / clifford.cpp
index d70f0f508706f3a8600b4abb6bfb6e4782204595..a66c835583de98b1c93d495707923997f99b7b04 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */
 
 /*
- *  GiNaC Copyright (C) 1999-2010 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2015 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
@@ -102,7 +102,7 @@ clifford::clifford(const ex & b, unsigned char rl) : inherited(b), representatio
  *  @see dirac_gamma */
 clifford::clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl, int comm_sign) : inherited(b, mu), representation_label(rl), metric(metr), commutator_sign(comm_sign)
 {
-       GINAC_ASSERT(is_a<varidx>(mu));
+       GINAC_ASSERT(is_a<idx>(mu));
 }
 
 clifford::clifford(unsigned char rl, const ex & metr, int comm_sign, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl), metric(metr), commutator_sign(comm_sign)
@@ -142,6 +142,7 @@ void clifford::archive(archive_node & n) const
 }
 
 GINAC_BIND_UNARCHIVER(clifford);
+GINAC_BIND_UNARCHIVER(cliffordunit);
 GINAC_BIND_UNARCHIVER(diracone);
 GINAC_BIND_UNARCHIVER(diracgamma);
 GINAC_BIND_UNARCHIVER(diracgamma5);
@@ -348,7 +349,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
 
        if (is_a<clifford>(*other)) {
 
-               // Contraction only makes sense if the represenation labels are equal
+               // Contraction only makes sense if the representation labels are equal
                if (ex_to<clifford>(*other).get_representation_label() != rl)
                        return false;
 
@@ -455,7 +456,7 @@ bool cliffordunit::contract_with(exvector::iterator self, exvector::iterator oth
        unsigned char rl = unit.get_representation_label();
 
        if (is_a<clifford>(*other)) {
-               // Contraction only makes sense if the represenation labels are equal
+               // Contraction only makes sense if the representation labels are equal
                // and the metrics are the same
                if ((ex_to<clifford>(*other).get_representation_label() != rl) 
                    && unit.same_metric(*other))
@@ -1132,7 +1133,7 @@ ex remove_dirac_ONE(const ex & e, unsigned char rl, unsigned options)
        return e1;
 }
 
-char clifford_max_label(const ex & e, bool ignore_ONE)
+int clifford_max_label(const ex & e, bool ignore_ONE)
 {
        if (is_a<clifford>(e))
                if (ignore_ONE && is_a<diracone>(e.op(0)))
@@ -1140,7 +1141,7 @@ char clifford_max_label(const ex & e, bool ignore_ONE)
                else
                        return ex_to<clifford>(e).get_representation_label();
        else {
-               char rl = -1;
+               int rl = -1;
                for (size_t i=0; i < e.nops(); i++) 
                        rl = (rl > clifford_max_label(e.op(i), ignore_ONE)) ? rl : clifford_max_label(e.op(i), ignore_ONE);
                return rl;
@@ -1228,8 +1229,7 @@ static ex get_clifford_comp(const ex & e, const ex & c)
                        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"));
                                }
                        }
@@ -1240,13 +1240,16 @@ static ex get_clifford_comp(const ex & e, const ex & c)
                        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;
+                       // Run through the expression collecting all non-clifford factors
                        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)));
+                                       } else {
+                                               exvector ind_vec;
+                                               if (is_a<indexed>(e.op(j)))
+                                                       ind_vec = ex_to<indexed>(e.op(j)).get_dummy_indices(ex_to<indexed>(e.op(ind)));
+                                               
                                                if (ind_vec.size() > 0) {
                                                        found_dummy = true;
                                                        exvector::const_iterator it = ind_vec.begin(), itend = ind_vec.end();
@@ -1291,11 +1294,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) {
@@ -1312,7 +1315,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())); 
                        }