Tensor contraction