From: Christian Bauer Date: Mon, 10 Jun 2002 21:30:50 +0000 (+0000) Subject: fixed a crash when constructing expressions like (dirac_ONE()+dirac_gamma5())*dirac_g... X-Git-Tag: release_1-0-9~2 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=af040268bde04a58accd189940927c191434ed1e;hp=759fd0ecbd27c082d89d69a5f77a71eef046f96a fixed a crash when constructing expressions like (dirac_ONE()+dirac_gamma5())*dirac_gamma5()*dirac_gamma5() --- diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index e3c0ffd4..66ddc019 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -305,12 +305,6 @@ ex clifford::simplify_ncmul(const exvector & v) const } } - // Remove squares of gamma5 - 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, itend = s.end() - 1; @@ -319,7 +313,9 @@ ex clifford::simplify_ncmul(const exvector & v) const ex & b = it[1]; if (!is_a(a) || !is_a(b)) continue; - if (is_a(a.op(0)) && is_a(b.op(0))) { + bool a_is_diracgamma = is_a(a.op(0)); + bool b_is_diracgamma = is_a(b.op(0)); + if (a_is_diracgamma && b_is_diracgamma) { const ex & ia = a.op(1); const ex & ib = b.op(1); if (ia.is_equal(ib)) { // gamma~alpha gamma~alpha -> g~alpha~alpha @@ -327,7 +323,12 @@ ex clifford::simplify_ncmul(const exvector & v) const b = dirac_ONE(representation_label); something_changed = true; } - } else if (!is_a(a.op(0)) && !is_a(b.op(0))) { + } else if (is_a(a.op(0)) && is_a(b.op(0))) { + // Remove squares of gamma5 + a = dirac_ONE(representation_label); + b = dirac_ONE(representation_label); + something_changed = true; + } else if (!a_is_diracgamma && !b_is_diracgamma) { const ex & ba = a.op(0); const ex & bb = b.op(0); if (ba.is_equal(bb)) { // a\ a\ -> a^2