X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fclifford.cpp;h=5b937c434806d95dc4441a38da3a43f38120dc73;hp=e5ebb4016ebc6958fc4a291eaf861962fcccfa6b;hb=bee5f67dae5b409bc53ff71cb98f6630832540e7;hpb=6e732baec20112b44eb0ed53a2833567bfa8749e diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index e5ebb401..5b937c43 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */ /* - * GiNaC Copyright (C) 1999-2010 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -102,7 +102,7 @@ clifford::clifford(const ex & b, unsigned char rl) : inherited(b), representatio * @see dirac_gamma */ clifford::clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl, int comm_sign) : inherited(b, mu), representation_label(rl), metric(metr), commutator_sign(comm_sign) { - GINAC_ASSERT(is_a(mu)); + GINAC_ASSERT(is_a(mu)); } clifford::clifford(unsigned char rl, const ex & metr, int comm_sign, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl), metric(metr), commutator_sign(comm_sign) @@ -1132,7 +1132,7 @@ ex remove_dirac_ONE(const ex & e, unsigned char rl, unsigned options) return e1; } -char clifford_max_label(const ex & e, bool ignore_ONE) +int clifford_max_label(const ex & e, bool ignore_ONE) { if (is_a(e)) if (ignore_ONE && is_a(e.op(0))) @@ -1140,7 +1140,7 @@ char clifford_max_label(const ex & e, bool ignore_ONE) else return ex_to(e).get_representation_label(); else { - char rl = -1; + int rl = -1; for (size_t i=0; i < e.nops(); i++) rl = (rl > clifford_max_label(e.op(i), ignore_ONE)) ? rl : clifford_max_label(e.op(i), ignore_ONE); return rl; @@ -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();