Tensor reshaping

In multilinear algebra, a reshaping of tensors is any bijection between the set of indices of an order-formula_1 tensor and the set of indices of an order-formula_2 tensor, where formula_3. 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-formula_1 tensors and the vector space of order-formula_2 tensors.
Definition.
Given a positive integer formula_1, the notation formula_7 refers to the set formula_8 of the first positive integers.
For each integer formula_9 where formula_10 for a positive integer formula_1, let "V""k" denote an "n""k"-dimensional vector space over a field formula_12. Then there are vector space isomorphisms (linear maps)
formula_13
where formula_14 is any permutation and formula_15 is the symmetric group on formula_1 elements. Via these (and other) vector space isomorphisms, a tensor can be interpreted in several ways as an order-formula_2 tensor where formula_18. 
Coordinate representation.
The first vector space isomorphism on the list above, formula_19, gives the coordinate representation of an abstract tensor. Assume that each of the formula_1 vector spaces formula_21 has a basis formula_22. The expression of a tensor with respect to this basis has the form formula_23 where the coefficients formula_24 are elements of formula_12. The coordinate representation of formula_26 is formula_27where formula_28 is the formula_29 standard basis vector of formula_30. This can be regarded as a "d"-dimensional array whose elements are the coefficients formula_24.
Vectorization.
By means of a bijective map formula_32, a vector space isomorphism between formula_33 and formula_34 is constructed via the mapping formula_35 where for every natural number formula_36 such that formula_37, the vector formula_38 denotes the "j"th standard basis vector of formula_39. In such a reshaping, the tensor is simply interpreted as a vector in formula_40. This is known as vectorization, and is analogous to vectorization of matrices. A standard choice of bijection formula_41 is such that 
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 formula_26 is the vector formula_44.
General flattenings.
For any permutation formula_14 there is a canonical isomorphism between the two tensor products of vector spaces formula_46 and formula_47. Parentheses are usually omitted from such products due to the natural isomorphism between formula_48 and formula_49, but may, of course, be reintroduced to emphasize a particular grouping of factors. In the grouping,
there are formula_2 groups with formula_52 factors in the formula_29 group (where formula_54 and formula_55).
Letting formula_56 for each formula_36 satisfying formula_58, an formula_59-flattening of a tensor formula_26, denoted formula_61, is obtained by applying the two processes above within each of the formula_2 groups of factors. That is, the coordinate representation of the formula_29 group of factors is obtained using the isomorphism formula_64, which requires specifying bases for all of the vector spaces formula_21. The result is then vectorized using a bijection formula_66 to obtain an element of formula_67, where formula_68, the product of the dimensions of the vector spaces in the formula_29 group of factors. The result of applying these isomorphisms within each group of factors is an element of formula_70, which is a tensor of order formula_2.
The vectorization of formula_26 is an formula_73-reshaping, formula_74 wherein formula_75.
Matricization.
Let formula_76 be the coordinate representation of an abstract tensor with respect to a basis.
A standard factor-"k" flattening of formula_26 is an formula_78-reshaping in which formula_79 and formula_80. Usually, a standard flattening is denoted by 
These reshapings are sometimes called matricizations or unfoldings in the literature. A standard choice for the bijections formula_82 is the one that is consistent with the reshape function in Matlab and GNU Octave, namely