({{, (RefLink[TensorDimensions, paclet:ref/TensorDimensions])[tensor] 
gives the list of dimensions of tensor.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[TensorDimensions, paclet:ref/TensorDimensions]) accepts any type of tensor, either symbolic or explicit, including any type of array.

On explicit rectangular arrays, (RefLink[TensorDimensions, paclet:ref/TensorDimensions]) coincides with (RefLink[Dimensions, paclet:ref/Dimensions]). On symbolic arrays, (RefLink[TensorDimensions, paclet:ref/TensorDimensions]) stays unevaluated unless the array has been assigned a rank through any form of assumption.

OpenersPrimaryExamplesSection(Spacer1)Examples  (9)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Dimensions of an array:

TensorDimensions[{{1,3},{2,Pi},{a,b}}]

Dimensions of a symbolic array expression:

$Assumptions={A∈Arrays[{2,d,4}],B∈Arrays[{d,d}]};

TensorDimensions[A⊗B]

OpenersExampleSection1(Spacer1)Scope  (3)

Dimensions of explicit arrays:

A=Array[a,{2,3,4}];
TensorDimensions[A]

A=SparseArray[{{1,2,3}->a},{2,3,4}];
TensorDimensions[A]

A=SymmetrizedArray[pos_:>a,{4,4,4},Symmetric[All]];
TensorDimensions[A]

Dimensions of symbolic arrays:

$Assumptions={
A∈Arrays[{4,4,5,5},Reals,Symmetric[{1,2}]],
M∈Matrices[{3,4},Reals],
V∈Vectors[5,Reals]
};

TensorDimensions[A]

TensorDimensions[M]

TensorDimensions[V]

Dimensions of general tensor expressions:

$Assumptions={
A∈Arrays[{4,5,5},Reals,Symmetric[{2,3}]],
M∈Matrices[{5,4},Reals]
};

TensorDimensions[A⊗M]

TensorRank[TensorContract[A⊗M,{{1,5},{2,3}}]]

TensorRank[TensorTranspose[A,{3,1,2}]]

OpenersExampleSection2(Spacer1)Options  (1)

OpenersExampleSubsection0(Spacer1)Assumptions  (1)

Specify locally the domain of a symbolic array:

TensorDimensions[A,Assumptions->A∈Arrays[{3,4,5}]]

OpenersExampleSection3(Spacer1)Properties & Relations  (2)

On explicit rectangular arrays, (RefLink[TensorDimensions, paclet:ref/TensorDimensions]) coincides with (RefLink[Dimensions, paclet:ref/Dimensions]):

A=Array[a,{2,3,4}];
{TensorDimensions[A],Dimensions[A]}

A=SparseArray[{{1,2,3}->a},{2,3,4}];
{TensorDimensions[A],Dimensions[A]}

A=SymmetrizedArray[pos_:>a,{4,4,4},Symmetric[All]];
{TensorDimensions[A],Dimensions[A]}

For symbolic expressions, there are no default dimensions assumed:

TensorDimensions[A]

Use assumptions to assign dimensions to the array:

Assuming[A∈Arrays[{3,4,d,d}],TensorDimensions[A]]

$Assumptions=A∈Arrays[{3,4,5}];
TensorDimensions[A]

OpenersExampleSection4(Spacer1)Possible Issues  (1)

It is not possible to mix incompatible local and global assumptions:

$Assumptions=A∈Arrays[{2,2,2,2}];

Assuming[A∈Arrays[{2,2}],TensorDimensions[A]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Dimensions, paclet:ref/Dimensions])  ▪  (RefLink[Arrays, paclet:ref/Arrays])  ▪  (RefLink[Matrices, paclet:ref/Matrices])  ▪  (RefLink[Vectors, paclet:ref/Vectors])  ▪  (RefLink[TensorRank, paclet:ref/TensorRank])  ▪  (RefLink[ArrayDepth, paclet:ref/ArrayDepth])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Symbolic Tensors, paclet:tutorial/SymbolicTensors])}, {▪(RefLinkPlain[Tensor Symmetries, paclet:tutorial/TensorSymmetries])}, {▪(RefLinkPlain[Symmetrized Arrays, paclet:tutorial/SymmetrizedArrays])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Symbolic Tensors, paclet:guide/SymbolicTensors])}})}})