]> www.ginac.de Git - ginac.git/blobdiff - ginac/clifford.cpp
- minor ISO cleanup.
[ginac.git] / ginac / clifford.cpp
index 8687f969777cbd11837aa181e2a69ab4229657c4..bee4618dba6ad2f03fcf74b7013faf5326bbe169 100644 (file)
@@ -148,7 +148,7 @@ bool clifford::match_same_type(const basic & other) const
        return representation_label == o.representation_label;
 }
 
-void clifford::print(const print_context & c, unsigned level = 0) const
+void clifford::print(const print_context & c, unsigned level) const
 {
        if (!is_a<diracgamma5>(seq[0]) && !is_a<diracgamma>(seq[0]) && !is_a<diracone>(seq[0])) {
 
@@ -281,7 +281,7 @@ ex clifford::simplify_ncmul(const exvector & v) const
        // Remove superfluous ONEs
        exvector::const_iterator cit = v.begin(), citend = v.end();
        while (cit != citend) {
-               if (!is_a<diracone>(cit->op(0)))
+               if (!is_a<clifford>(*cit) || !is_a<diracone>(cit->op(0)))
                        s.push_back(*cit);
                cit++;
        }
@@ -296,7 +296,7 @@ ex clifford::simplify_ncmul(const exvector & v) const
                        exvector::iterator it = next_to_last;
                        while (true) {
                                exvector::iterator it2 = it + 1;
-                               if (!is_a<diracgamma5>(it->op(0)) && is_a<diracgamma5>(it2->op(0))) {
+                               if (is_a<clifford>(*it) && is_a<clifford>(*it2) && !is_a<diracgamma5>(it->op(0)) && is_a<diracgamma5>(it2->op(0))) {
                                        it->swap(*it2);
                                        sign = -sign;
                                        something_changed = true;
@@ -312,17 +312,19 @@ ex clifford::simplify_ncmul(const exvector & v) const
        }
 
        // Remove squares of gamma5
-       while (s.size() >= 2 && is_a<diracgamma5>(s[0].op(0)) && is_a<diracgamma5>(s[1].op(0))) {
+       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 = s.begin(), itend = s.end() - 1;
-               while (it != itend) {
+               exvector::iterator it, itend = s.end() - 1;
+               for (it = s.begin(); it != itend; ++it) {
                        ex & a = it[0];
                        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))) {
                                const ex & ia = a.op(1);
                                const ex & ib = b.op(1);
@@ -341,7 +343,6 @@ ex clifford::simplify_ncmul(const exvector & v) const
                                        something_changed = true;
                                }
                        }
-                       ++it;
                }
        }