X-Git-Url: https://ginac.de/ginac.git//ginac.git?a=blobdiff_plain;ds=inline;f=ginac%2Fclifford.cpp;h=13bb8b0e7010a30f02d0ee0c777c84ba960017d2;hb=e5d3bf4cb7ffe363ff7e820090649122b8ca689f;hp=8687f969777cbd11837aa181e2a69ab4229657c4;hpb=834bacb25c9427fb03b8f9b34605738fb59202e1;p=ginac.git diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 8687f969..13bb8b0e 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -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(cit->op(0))) + if (!is_a(*cit) || !is_a(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(it->op(0)) && is_a(it2->op(0))) { + if (is_a(*it) && is_a(*it2) && !is_a(it->op(0)) && is_a(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(s[0].op(0)) && is_a(s[1].op(0))) { + while (s.size() >= 2 && is_a(s[0]) && is_a(s[1]) && is_a(s[0].op(0)) && is_a(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(a) || !is_a(b)) + continue; if (is_a(a.op(0)) && is_a(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; } }