Skip to content

Shape ​

Generated from the engine's own definition: compute-engine's symbol, which we neither extend nor document by hand.

Return the shape tuple of an expression.

✓ checked against that system · ! checked, with disagreements (hover a chip)FindStatMp00077via SemistandardTableauMp00079via SetPartitionMp00083via StandardTableauWolfram LanguageDimensions!
Shape(value) -> tuplereads a nested list's own structure when its elements' type carries no dimensions, as Wolfram's Dimensions does
Typed signatures
TypePackageApplies
(value) -> tupleanalyticreplaces compute-enginealways
(value) -> tuplecompute-enginealways
(value) -> tupleevaluationreplaces compute-enginealways

Domain: Compute engine

Examples

Scope #

Four nested levels, with length 2 innermost

live ↗
InShape([[[[a,b]]]])\mathrm{Shape}(\bigl\lbrack\bigl\lbrack\bigl\lbrack\bigl\lbrack a, b\bigr\rbrack\bigr\rbrack\bigr\rbrack\bigr\rbrack)Out(1,1,1,2)(1,1,1,2)
Properties #

A scalar has an empty shape

live ↗
InShape(1)\mathrm{Shape}(1)Out()()

A flat list has a one-entry shape, its length

live ↗
InShape([1,2])\mathrm{Shape}(\bigl\lbrack1, 2\bigr\rbrack)Out(2,)(2,)

A one-row matrix has shape (1,2)(1, 2)

live ↗
InShape([[1,2]])\mathrm{Shape}(\bigl\lbrack\bigl\lbrack1, 2\bigr\rbrack\bigr\rbrack)Out(1,2)(1,2)

The length of the shape is the tensor's rank

live ↗
InLength(Shape([[a,b],[c,d]]))=Rank([[a,b],[c,d]])\mathrm{Length}(\mathrm{Shape}(\bigl\lbrack\bigl\lbrack a, b\bigr\rbrack, \bigl\lbrack c, d\bigr\rbrack\bigr\rbrack))=\mathrm{Rank}(\bigl\lbrack\bigl\lbrack a, b\bigr\rbrack, \bigl\lbrack c, d\bigr\rbrack\bigr\rbrack)OutTrue\mathrm{True}
live ↗
InShape(Array(a,[2,1,4,3]))\mathrm{Shape}(\mathrm{Array}(a, \bigl\lbrack2, 1, 4, 3\bigr\rbrack))Out(2,1,4,3)(2,1,4,3)
Possible issues #
live ↗
InShape(2)\mathrm{Shape}(\sqrt{2})Out()()
About
Examples7
Checked againstWolfram Language 6 agree1 differ
CrosswalkFindStat ×3Wolfram Language