Mode-k flattening



In multilinear algebra, mode-m flattening, also known as matrixizing, matricizing, or unfolding, is an operation that reshapes a multi-way array $$\mathcal{A}$$ into a matrix denoted by $$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 $${\mathcal A} \in {\mathbb C}^{I_0\times I_1\times\cdots\times I_M},$$ is defined as the matrix $${\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

$$[{\bf A}_{[m]}]_{jk} = a_{i_1\dots i_m\dots i_M},$$ where $$j=i_m$$ and $$ 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 $${\bf A}_{[m]} \in {\mathbb C}^{I_m \times (I_{m+1} \dots I_M I_0I_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.