+/** Contraction of epsilon tensor with something else. */
+bool tensepsilon::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(is_a<tensepsilon>(self->op(0)));
+ size_t num = self->nops() - 1;
+
+ if (is_exactly_a<tensepsilon>(other->op(0)) && num+1 == other->nops()) {
+
+ // Contraction of two epsilon tensors is a determinant
+ bool variance = is_a<varidx>(self->op(1));
+ matrix M(num, num);
+ for (size_t i=0; i<num; i++) {
+ for (size_t j=0; j<num; j++) {
+ if (minkowski)
+ M(i, j) = lorentz_g(self->op(i+1), other->op(j+1), pos_sig);
+ else if (variance)
+ M(i, j) = metric_tensor(self->op(i+1), other->op(j+1));
+ else
+ M(i, j) = delta_tensor(self->op(i+1), other->op(j+1));
+ }
+ }
+ int sign = minkowski ? -1 : 1;
+ *self = sign * M.determinant().simplify_indexed();
+ *other = _ex1;
+ return true;
+ }
+
+ return false;
+}
+