From: Vladimir V. Kisil Date: Thu, 23 Jun 2011 14:20:59 +0000 (+0200) Subject: Be more careful before converting to indexed. X-Git-Tag: release_1-6-1~1 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=29b8244d6141ecb6f8d90480ade69af407270441 Be more careful before converting to indexed. This patch makes GiNaC pass it's test suite when compiled with -DDO_GINAC_ASSERT. --- diff --git a/check/exam_clifford.cpp b/check/exam_clifford.cpp index f504cd0e..9503f162 100644 --- a/check/exam_clifford.cpp +++ b/check/exam_clifford.cpp @@ -504,7 +504,8 @@ static unsigned clifford_check7(const ex & G, const symbol & dim) result += check_equal(e, pow(scalar*(dim-2), 2).expand() * clifford_unit(mu, G)); // canonicalize_clifford() checks, only for symmetric metrics - if (ex_to(ex_to(ex_to(clifford_unit(mu, G)).get_metric()).get_symmetry()).has_symmetry()) { + if (is_a(ex_to(clifford_unit(mu, G)).get_metric()) && + ex_to(ex_to(ex_to(clifford_unit(mu, G)).get_metric()).get_symmetry()).has_symmetry()) { e = clifford_unit(mu, G) * clifford_unit(nu, G) + clifford_unit(nu, G) * clifford_unit(mu, G); result += check_equal(canonicalize_clifford(e), 2*dirac_ONE()*unit.get_metric(nu, mu)); diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 67250069..5b937c43 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -1228,8 +1228,7 @@ static ex get_clifford_comp(const ex & e, const ex & c) if (is_a(e.op(j)) && ex_to(c).same_metric(e.op(j))) { if (ind > e.nops()) { ind = j; - } - else { + } else { throw(std::invalid_argument("get_clifford_comp(): expression is a Clifford multi-vector")); } } @@ -1240,13 +1239,16 @@ static ex get_clifford_comp(const ex & e, const ex & c) same_value_index = ( ex_to(e.op(ind).op(1)).is_numeric() && (ival == ex_to(ex_to(e.op(ind).op(1)).get_value()).to_int()) ); found_dummy = same_value_index; + // Run through the expression collecting all non-clifford factors for (size_t j=0; j < e.nops(); j++) { if (j != ind) { if (same_value_index) { S = S * e.op(j); - } - else { - exvector ind_vec = ex_to(e.op(j)).get_dummy_indices(ex_to(e.op(ind))); + } else { + exvector ind_vec; + if (is_a(e.op(j))) + ind_vec = ex_to(e.op(j)).get_dummy_indices(ex_to(e.op(ind))); + if (ind_vec.size() > 0) { found_dummy = true; exvector::const_iterator it = ind_vec.begin(), itend = ind_vec.end();