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 allBasic Examples (3)
Scope (3)
Generalizations & Extensions (1)
With arrays it is possible to use contractions of more than two slots, using the function SymbolicTensors`ArrayContract:
It is also possible to specify an arbitrary head, generalizing the role of Plus:
The contraction can be performed in such a way that levels stay inside the contraction head g:
Properties & Relations (8)
Contraction of the first levels of an array is equivalent to Tr:
Contraction of a tensor product of arrays is equivalent to Dot and Inner:
Inner performs one contraction between two arrays:
Dot with arguments performs contractions among them:
Arbitrary contractions can be also performed with a combination of Transpose and Apply:
Contraction of antisymmetric pairs of array levels gives zero:
Since levels one and three are not an antisymmetric pair, the result is not zero:
Contraction of antisymmetric symbolic arrays gives zero:
In other cases, the expression is canonicalized, moving contractions to the last possible slots:
TensorContract[tensor,{}] returns tensor, irrespectively of what tensor is:
TensorContract, in combination with TensorProduct, can be used to implement Dot:
Text
Wolfram Research (2012), TensorContract, Wolfram Language function, https://reference.wolfram.com/language/ref/TensorContract.html.
CMS
Wolfram Language. 2012. "TensorContract." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TensorContract.html.
APA
Wolfram Language. (2012). TensorContract. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TensorContract.html