- if (ind < e.nops()) {
- ex S = 1;
- bool same_value_index, found_dummy;
- same_value_index = ( ex_to<idx>(e.op(ind).op(1)).is_numeric()
- && (ival == ex_to<numeric>(ex_to<idx>(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;
- if (is_a<indexed>(e.op(j)))
- ind_vec = ex_to<indexed>(e.op(j)).get_dummy_indices(ex_to<indexed>(e.op(ind)));
-
- if (ind_vec.size() > 0) {
- found_dummy = true;
- for (auto & it : ind_vec) {
- ex curridx = it;
- ex curridx_toggle = is_a<varidx>(curridx)
- ? ex_to<varidx>(curridx).toggle_variance()
- : curridx;
- S = S * e.op(j).subs(lst{curridx == ival, curridx_toggle == ival},
- subs_options::no_pattern);
- }
- } else
- S = S * e.op(j);
- }
- }
- }
- return (found_dummy ? S : 0);
- } else