# TensorContract

TensorContract[tensor,{{s11,s12},{s21,s22},}]

yields the contraction of tensor in the pairs {si1,si2} of slots.

# Details

• The first argument of TensorContract[tensor,pairs] can be any tensorial object, in particular explicit or symbolic arrays, or combinations like tensor products, transpositions, etc.
• The slots sij must all be different positive integers, not larger than the rank of the contracted tensor.
• The slots contracted in each pair must all have the same dimensions, but different pairs might be associated to different dimensions.
• For a symbolic tensor in the first argument of TensorContract, the contractions in the second argument are sorted, after sorting the slots in each contraction.
• TensorContract[tensor,{}] returns tensor.

# Examples

open allclose all

## Basic Examples(3)

Contract slots 2 and 3 of a rank-3 array:

 In[1]:=
 Out[1]=

Perform several contractions in an array:

 In[1]:=
 In[2]:=
 Out[2]=

A symbolic array of rank 3:

 In[1]:=

Slots 1 and 3 can be contracted:

 In[2]:=
 Out[2]=

Slots 1 and 2 cannot be contracted:

 In[3]:=
 Out[3]=