In multilinear algebra, a reshaping of tensors is any bijection between the set of indices of an order-
tensor and the set of indices of an order-
tensor, where
. The use of indices presupposes tensors in coordinate representation with respect to a basis. The coordinate representation of a tensor can be regarded as a multi-dimensional array, and a bijection from one set of indices to another therefore amounts to a rearrangement of the array elements into an array of a different shape. Such a rearrangement constitutes a particular kind of linear map between the vector space of order-
tensors and the vector space of order-
tensors.
Definition
Given a positive integer
, the notation
refers to the set
of the first d positive integers.
For each integer
where
for a positive integer
, let Vk denote an nk-dimensional vector space over a field
. Then there are vector space isomorphisms (linear maps)
where
is any permutation and
is the symmetric group on
elements. Via these (and other) vector space isomorphisms, a tensor can be interpreted in several ways as an order-
tensor where
.
Coordinate representation
The first vector space isomorphism on the list above,
, gives the coordinate representation of an abstract tensor. Assume that each of the
vector spaces
has a basis
. The expression of a tensor with respect to this basis has the form
where the coefficients
are elements of
. The coordinate representation of
is
where
is the
standard basis vector of
. This can be regarded as a d-dimensional array whose elements are the coefficients
.
Vectorization
By means of a bijective map
, a vector space isomorphism between
and
is constructed via the mapping
where for every natural number
such that
, the vector
denotes the jth standard basis vector of
. In such a reshaping, the tensor is simply interpreted as a vector in
. This is known as vectorization, and is analogous to vectorization of matrices. A standard choice of bijection
is such that
![{\displaystyle \operatorname {vec} ({\mathcal {A}}):={\begin{bmatrix}a_{1,1,\ldots ,1}&a_{2,1,\ldots ,1}&\cdots &a_{n_{1},1,\ldots ,1}&a_{1,2,1,\ldots ,1}&\cdots &a_{n_{1},n_{2},\ldots ,n_{d}}\end{bmatrix}}^{T},}](https://wikimedia.org/api/rest_v1/media/math/render/svg/0393be8f235585c533195554781edc997bcbea34)
which is consistent with the way in which the colon operator in Matlab and GNU Octave reshapes a higher-order tensor into a vector. In general, the vectorization of
is the vector
.
General flattenings
For any permutation
there is a canonical isomorphism between the two tensor products of vector spaces
and
. Parentheses are usually omitted from such products due to the natural isomorphism between
and
, but may, of course, be reintroduced to emphasize a particular grouping of factors. In the grouping,
![{\displaystyle (V_{\pi (1)}\otimes \cdots \otimes V_{\pi (r_{1})})\otimes (V_{\pi (r_{1}+1)}\otimes \cdots \otimes V_{\pi (r_{2})})\otimes \cdots \otimes (V_{\pi (r_{\ell -1}+1)}\otimes \cdots \otimes V_{\pi (r_{\ell })}),}](https://wikimedia.org/api/rest_v1/media/math/render/svg/2e8a7620c589fca30735daa810f695a96913c454)
there are
groups with
factors in the
group (where
and
).
Letting
for each
satisfying
, an
-flattening of a tensor
, denoted
, is obtained by applying the two processes above within each of the
groups of factors. That is, the coordinate representation of the
group of factors is obtained using the isomorphism
, which requires specifying bases for all of the vector spaces
. The result is then vectorized using a bijection
to obtain an element of
, where
, the product of the dimensions of the vector spaces in the
group of factors. The result of applying these isomorphisms within each group of factors is an element of
, which is a tensor of order
.
The vectorization of
is an
-reshaping,
wherein
.
Matricization
Let
be the coordinate representation of an abstract tensor with respect to a basis.
A standard factor-k flattening of
is an
-reshaping in which
and
. Usually, a standard flattening is denoted by
![{\displaystyle {\mathcal {A}}_{(k)}:={\mathcal {A}}_{(S_{1},S_{2})}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/08fc2791b57cd6ebd40c7366f7a31440e662822f)
These reshapings are sometimes called matricizations or unfoldings in the literature. A standard choice for the bijections
is the one that is consistent with the reshape function in Matlab and GNU Octave, namely
![{\displaystyle {\mathcal {A}}_{(k)}:={\begin{bmatrix}a_{1,1,\ldots ,1,1,1,\ldots ,1}&a_{2,1,\ldots ,1,1,1,\ldots ,1}&\cdots &a_{n_{1},n_{2},\ldots ,n_{k-1},1,n_{k+1},\ldots ,n_{d}}\\a_{1,1,\ldots ,1,2,1,\ldots ,1}&a_{2,1,\ldots ,1,2,1,\ldots ,1}&\cdots &a_{n_{1},n_{2},\ldots ,n_{k-1},2,n_{k+1},\ldots ,n_{d}}\\\vdots &\vdots &&\vdots \\a_{1,1,\ldots ,1,n_{k},1,\ldots ,1}&a_{2,1,\ldots ,1,n_{k},1,\ldots ,1}&\cdots &a_{n_{1},n_{2},\ldots ,n_{k-1},n_{k},n_{k+1},\ldots ,n_{d}}\end{bmatrix}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/ac0f66463806b9334185a60afc04ac75640e06d2)