In multilinear algebra, mode-m flattening, also known as matrixizing, matricizing is an operation that reshapes a multi-way array A {\displaystyle {\mathcal {A}}} into a matrix denoted by A [ m ] {\displaystyle A_{[m]}} (a two-way array). Matrixizing may be regarded as a generalization of the mathematical concept of vectorizing.
Definition The mode-m matrixizing of tensor A ∈ C I 0 × I 1 × ⋯ × I M , {\displaystyle {\mathcal {A}}\in {\mathbb {C} }^{I_{0}\times I_{1}\times \cdots \times I_{M}},} is defined as the matrix A [ m ] ∈ C I m × ( I 0 … I m − 1 I m + 1 … I M ) {\displaystyle {\bf {A}}_{[m]}\in {\mathbb {C} }^{I_{m}\times (I_{0}\dots I_{m-1}I_{m+1}\dots I_{M})}} . As the parenthetical ordering indicates, the mode-m column vectors are arranged by sweeping all the other mode indices through their ranges, with smaller mode indexes varying more rapidly than larger ones; thus
[ A [ m ] ] j k = a i 1 … i m … i M , {\displaystyle [{\bf {A}}_{[m]}]_{jk}=a_{i_{1}\dots i_{m}\dots i_{M}},}
where j = i m {\displaystyle j=i_{m}} and
k = 1 + ∑ n = 0 n ≠ m M ( i n − 1 ) ∏ ℓ = 0 ℓ ≠ m n − 1 I ℓ . {\displaystyle k=1+\sum _{n=0 \atop n\neq m}^{M}(i_{n}-1)\prod _{\ell =0 \atop \ell \neq m}^{n-1}I_{\ell }.}
By comparison, the matrix A [ m ] ∈ C I m × ( I m + 1 … I M I 0 I 1 … I m − 1 ) {\displaystyle {\bf {A}}_{[m]}\in {\mathbb {C} }^{I_{m}\times (I_{m+1}\dots I_{M}I_{0}I_{1}\dots I_{m-1})}} that results from an unfolding has columns that are the result of sweeping through all the modes in a circular manner beginning with mode m + 1 as seen in the parenthetical ordering. This is an inefficient way to matrixize.
Applications This operation is used in tensor algebra and its methods, such as Parafac and HOSVD.
References

![Mode-k flattening: Flattening a (3rd-order) tensor. The tensor can be flattened in three ways to obtain matrices comprising its mode-0, mode-1, and mode-2 vectors.[1]](https://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Flatten3_new_w_i0_6.png/330px-Flatten3_new_w_i0_6.png?utm_source=en.wikipedia.org&utm_campaign=parser&utm_content=thumbnail)
