+ if (is_a<tensdelta>(other->op(0)))
+ return false;
+
+ // Replace the dummy index with this tensor's other index and remove
+ // the tensor
+ return replace_contr_index(self, other);
+}
+
+/** Contraction of an indexed spinor metric with something else. */
+bool spinmetric::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
+{
+ GINAC_ASSERT(is_a<indexed>(*self));
+ GINAC_ASSERT(is_a<indexed>(*other));
+ GINAC_ASSERT(self->nops() == 3);
+ GINAC_ASSERT(is_a<spinmetric>(self->op(0)));
+
+ // Contractions between spinor metrics
+ if (is_a<spinmetric>(other->op(0))) {
+ const idx &self_i1 = ex_to<idx>(self->op(1));
+ const idx &self_i2 = ex_to<idx>(self->op(2));
+ const idx &other_i1 = ex_to<idx>(other->op(1));
+ const idx &other_i2 = ex_to<idx>(other->op(2));
+
+ if (is_dummy_pair(self_i1, other_i1)) {
+ if (is_dummy_pair(self_i2, other_i2))
+ *self = _ex2;
+ else
+ *self = delta_tensor(self_i2, other_i2);
+ *other = _ex1;
+ return true;
+ } else if (is_dummy_pair(self_i1, other_i2)) {
+ if (is_dummy_pair(self_i2, other_i1))
+ *self = _ex_2;
+ else
+ *self = -delta_tensor(self_i2, other_i1);
+ *other = _ex1;
+ return true;
+ } else if (is_dummy_pair(self_i2, other_i1)) {
+ *self = -delta_tensor(self_i1, other_i2);
+ *other = _ex1;
+ return true;
+ } else if (is_dummy_pair(self_i2, other_i2)) {
+ *self = delta_tensor(self_i1, other_i1);
+ *other = _ex1;
+ return true;
+ }
+ }
+
+ // If contracting with the delta tensor, let the delta do it
+ // (don't raise/lower delta indices)
+ if (is_a<tensdelta>(other->op(0)))