]> www.ginac.de Git - ginac.git/blobdiff - ginac/clifford.cpp
some cleanups
[ginac.git] / ginac / clifford.cpp
index c985bd8dba75edd189684c8120e7d7d7d4e31c6e..80d7d3426a58d430ff8b33ccbc88527b2c69b5da 100644 (file)
@@ -128,7 +128,7 @@ DEFAULT_ARCHIVING(diracgamma5)
 
 int clifford::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(other.tinfo() == TINFO_clifford);
+       GINAC_ASSERT(is_of_type(other, clifford));
        const clifford &o = static_cast<const clifford &>(other);
 
        if (representation_label != o.representation_label) {
@@ -139,6 +139,14 @@ int clifford::compare_same_type(const basic & other) const
        return inherited::compare_same_type(other);
 }
 
+bool clifford::match_same_type(const basic & other) const
+{
+       GINAC_ASSERT(is_of_type(other, clifford));
+       const clifford &o = static_cast<const clifford &>(other);
+
+       return representation_label == o.representation_label;
+}
+
 DEFAULT_COMPARE(diracone)
 DEFAULT_COMPARE(diracgamma)
 DEFAULT_COMPARE(diracgamma5)
@@ -153,11 +161,11 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
        GINAC_ASSERT(is_ex_of_type(*self, clifford));
        GINAC_ASSERT(is_ex_of_type(*other, indexed));
        GINAC_ASSERT(is_ex_of_type(self->op(0), diracgamma));
-       unsigned char rl = ex_to_clifford(*self).get_representation_label();
+       unsigned char rl = ex_to<clifford>(*self).get_representation_label();
 
        if (is_ex_of_type(*other, clifford)) {
 
-               ex dim = ex_to_idx(self->op(1)).get_dim();
+               ex dim = ex_to<idx>(self->op(1)).get_dim();
 
                // gamma~mu gamma.mu = dim ONE
                if (other - self == 1) {
@@ -190,7 +198,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
                        while (it != other) {
                                if (!is_ex_of_type(*it, clifford))
                                        return false;
-                               it++;
+                               ++it;
                        }
 
                        it = self + 1;
@@ -243,11 +251,11 @@ ex clifford::simplify_ncmul(const exvector & v) const
                                }
                                if (it == first)
                                        break;
-                               it--;
+                               --it;
                        }
                        if (next_to_last == first)
                                break;
-                       next_to_last--;
+                       --next_to_last;
                }
        }
 
@@ -272,11 +280,11 @@ ex clifford::simplify_ncmul(const exvector & v) const
                                        something_changed = true;
                                }
                        }
-                       it++;
+                       ++it;
                }
        }
 
-       if (s.size() == 0)
+       if (s.empty())
                return clifford(diracone(), representation_label) * sign;
        if (something_changed)
                return nonsimplified_ncmul(s) * sign;
@@ -386,7 +394,7 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
 {
        if (is_ex_of_type(e, clifford)) {
 
-               if (ex_to_clifford(e).get_representation_label() == rl
+               if (ex_to<clifford>(e).get_representation_label() == rl
                 && is_ex_of_type(e.op(0), diracone))
                        return trONE;
                else
@@ -526,7 +534,7 @@ ex canonicalize_clifford(const ex & e)
                        // Stupid recursive bubble sort because we only want to swap adjacent gammas
                        exvector::iterator it = v.begin(), next_to_last = v.end() - 1;
                        if (is_ex_of_type(it->op(0), diracgamma5))
-                               it++;
+                               ++it;
                        while (it != next_to_last) {
                                if (it[0].op(1).compare(it[1].op(1)) > 0) {
                                        ex save0 = it[0], save1 = it[1];
@@ -539,7 +547,7 @@ ex canonicalize_clifford(const ex & e)
                                        srl.let_op(i) = (lhs == canonicalize_clifford(sum));
                                        goto next_sym;
                                }
-                               it++;
+                               ++it;
                        }
 next_sym:      ;
                }