]> www.ginac.de Git - ginac.git/blobdiff - ginac/clifford.cpp
* Ctors of class numeric are not explicit any more. All built-in callers for
[ginac.git] / ginac / clifford.cpp
index c985bd8dba75edd189684c8120e7d7d7d4e31c6e..cde94ebd640b080f091ca7b63407444bd5fbd73d 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;
@@ -370,8 +378,8 @@ static ex trace_string(exvector::const_iterator ix, unsigned num)
        exvector v(num - 2);
        int sign = 1;
        ex result;
-       for (int i=1; i<num; i++) {
-               for (int n=1, j=0; n<num; n++) {
+       for (unsigned i=1; i<num; i++) {
+               for (unsigned n=1, j=0; n<num; n++) {
                        if (n == i)
                                continue;
                        v[j++] = ix[n];
@@ -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
@@ -398,7 +406,6 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
                ex prod = _ex1();
                for (unsigned i=0; i<e.nops(); i++) {
                        const ex &o = e.op(i);
-                       unsigned ti = o.return_type_tinfo();
                        if (is_clifford_tinfo(o.return_type_tinfo(), rl))
                                prod *= dirac_trace(o, rl, trONE);
                        else
@@ -440,18 +447,18 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
                        num--;
                        int *iv = new int[num];
                        ex result;
-                       for (int i=0; i<num-3; i++) {
+                       for (unsigned i=0; i<num-3; i++) {
                                ex idx1 = ix[i];
-                               for (int j=i+1; j<num-2; j++) {
+                               for (unsigned j=i+1; j<num-2; j++) {
                                        ex idx2 = ix[j];
-                                       for (int k=j+1; k<num-1; k++) {
+                                       for (unsigned k=j+1; k<num-1; k++) {
                                                ex idx3 = ix[k];
-                                               for (int l=k+1; l<num; l++) {
+                                               for (unsigned l=k+1; l<num; l++) {
                                                        ex idx4 = ix[l];
                                                        iv[0] = i; iv[1] = j; iv[2] = k; iv[3] = l;
                                                        exvector v;
                                                        v.reserve(num - 4);
-                                                       for (int n=0, t=4; n<num; n++) {
+                                                       for (unsigned n=0, t=4; n<num; n++) {
                                                                if (n == i || n == j || n == k || n == l)
                                                                        continue;
                                                                iv[t++] = n;
@@ -526,7 +533,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 +546,7 @@ ex canonicalize_clifford(const ex & e)
                                        srl.let_op(i) = (lhs == canonicalize_clifford(sum));
                                        goto next_sym;
                                }
-                               it++;
+                               ++it;
                        }
 next_sym:      ;
                }