HOME

TheInfoList



OR:

In
mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, especially in
linear algebra Linear algebra is the branch of mathematics concerning linear equations such as: :a_1x_1+\cdots +a_nx_n=b, linear maps such as: :(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n, and their representations in vector spaces and through matrice ...
and matrix theory, the vectorization of a
matrix Matrix most commonly refers to: * ''The Matrix'' (franchise), an American media franchise ** '' The Matrix'', a 1999 science-fiction action film ** "The Matrix", a fictional setting, a virtual reality environment, within ''The Matrix'' (franchi ...
is a
linear transformation In mathematics, and more specifically in linear algebra, a linear map (also called a linear mapping, linear transformation, vector space homomorphism, or in some contexts linear function) is a mapping V \to W between two vector spaces that pre ...
which converts the matrix into a
column vector In linear algebra, a column vector with m elements is an m \times 1 matrix consisting of a single column of m entries, for example, \boldsymbol = \begin x_1 \\ x_2 \\ \vdots \\ x_m \end. Similarly, a row vector is a 1 \times n matrix for some n, c ...
. Specifically, the vectorization of a matrix ''A'', denoted vec(''A''), is the column vector obtained by stacking the columns of the matrix ''A'' on top of one another: :\operatorname(A) = _, \ldots, a_, a_, \ldots, a_, \ldots, a_, \ldots, a_\mathrm Here, a_ represents A(i,j) and the superscript ^\mathrm denotes the
transpose In linear algebra, the transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix by producing another matrix, often denoted by (among other notations). The tr ...
. Vectorization expresses, through coordinates, the
isomorphism In mathematics, an isomorphism is a structure-preserving mapping between two structures of the same type that can be reversed by an inverse mapping. Two mathematical structures are isomorphic if an isomorphism exists between them. The word i ...
\mathbf^ := \mathbf^m \otimes \mathbf^n \cong \mathbf^ between these (i.e., of matrices and vectors) as vector spaces. For example, for the 2×2 matrix A = \begin a & b \\ c & d \end, the vectorization is \operatorname(A) = \begin a \\ c \\ b \\ d \end. The connection between the vectorization of ''A'' and the vectorization of its transpose is given by the commutation matrix.


Compatibility with Kronecker products

The vectorization is frequently used together with the
Kronecker product In mathematics, the Kronecker product, sometimes denoted by ⊗, is an operation on two matrices of arbitrary size resulting in a block matrix. It is a generalization of the outer product (which is denoted by the same symbol) from vectors to ...
to express
matrix multiplication In mathematics, particularly in linear algebra, matrix multiplication is a binary operation that produces a matrix from two matrices. For matrix multiplication, the number of columns in the first matrix must be equal to the number of rows in the s ...
as a linear transformation on matrices. In particular, : \operatorname(ABC) = (C^\mathrm\otimes A) \operatorname(B) for matrices ''A'', ''B'', and ''C'' of dimensions ''k''×''l'', ''l''×''m'', and ''m''×''n''. For example, if \operatorname_A(X) = AX-XA (the adjoint endomorphism of the
Lie algebra In mathematics, a Lie algebra (pronounced ) is a vector space \mathfrak g together with an operation called the Lie bracket, an alternating bilinear map \mathfrak g \times \mathfrak g \rightarrow \mathfrak g, that satisfies the Jacobi identi ...
of all ''n''×''n'' matrices with complex entries), then \operatorname(\operatorname_A(X)) = (I_n\otimes A - A^\mathrm \otimes I_n ) \text(X), where I_n is the ''n''×''n''
identity matrix In linear algebra, the identity matrix of size n is the n\times n square matrix with ones on the main diagonal and zeros elsewhere. Terminology and notation The identity matrix is often denoted by I_n, or simply by I if the size is immaterial or ...
. There are two other useful formulations: : \operatorname(ABC)=(I_n\otimes AB)\operatorname(C) =(C^\mathrmB^\mathrm\otimes I_k)\operatorname(A) : \operatorname(AB)=(I_m\otimes A)\operatorname(B) =(B^\mathrm\otimes I_k)\operatorname(A) More generally, it has been shown that vectorization is a self-adjunction in the monoidal closed structure of any category of matrices.


Compatibility with Hadamard products

Vectorization is an
algebra homomorphism In mathematics, an algebra homomorphism is a homomorphism between two associative algebras. More precisely, if and are algebras over a field (or commutative ring) , it is a function F\colon A\to B such that for all in and in , * F(kx) = kF( ...
from the space of matrices with the Hadamard (entrywise) product to C''n''2 with its Hadamard product: :\operatorname(A \circ B) = \operatorname(A) \circ \operatorname(B) .


Compatibility with inner products

Vectorization is a
unitary transformation In mathematics, a unitary transformation is a transformation that preserves the inner product: the inner product of two vectors before the transformation is equal to their inner product after the transformation. Formal definition More precisely, ...
from the space of ''n''×''n'' matrices with the Frobenius (or Hilbert–Schmidt)
inner product In mathematics, an inner product space (or, rarely, a Hausdorff pre-Hilbert space) is a real vector space or a complex vector space with an operation called an inner product. The inner product of two vectors in the space is a scalar, often ...
to C''n''2 : :\operatorname(A^\top B) = \operatorname(A)^\top \operatorname(B) = \operatorname(B)^\top \operatorname(A). where the superscript T denotes the
conjugate transpose In mathematics, the conjugate transpose, also known as the Hermitian transpose, of an m \times n complex matrix \boldsymbol is an n \times m matrix obtained by transposing \boldsymbol and applying complex conjugate on each entry (the complex c ...
.


Vectorization as a linear sum

The matrix vectorization operation can be written in terms of a linear sum. Let X be an matrix that we want to vectorize, and let e''i'' be the ''i''-th canonical basis vector for the ''n''-dimensional space, that is \mathbf_i=\left ,...,0,1,0,...,0\right\mathrm. Let B''i'' be a block matrix defined as follows: \mathbf_i = \begin \mathbf \\ \vdots \\ \mathbf \\ \mathbf_m \\ \mathbf \\ \vdots \\ \mathbf \end = \mathbf_i \otimes \mathbf_m B''i'' consists of ''n'' block matrices of size , stacked column-wise, and all these matrices are all-zero except for the ''i''-th one, which is a identity matrix I''m''. Then the vectorized version of X can be expressed as follows: :\operatorname(\mathbf) = \sum_^n \mathbf_i \mathbf \mathbf_i Multiplication of X by e''i'' extracts the ''i''-th column, while multiplication by B''i'' puts it into the desired position in the final vector. Alternatively, the linear sum can be expressed using the
Kronecker product In mathematics, the Kronecker product, sometimes denoted by ⊗, is an operation on two matrices of arbitrary size resulting in a block matrix. It is a generalization of the outer product (which is denoted by the same symbol) from vectors to ...
: :\operatorname(\mathbf) = \sum_^n \mathbf_i \otimes \mathbf \mathbf_i


Half-vectorization

For a
symmetric matrix In linear algebra, a symmetric matrix is a square matrix that is equal to its transpose. Formally, Because equal matrices have equal dimensions, only square matrices can be symmetric. The entries of a symmetric matrix are symmetric with ...
''A'', the vector vec(''A'') contains more information than is strictly necessary, since the matrix is completely determined by the symmetry together with the lower triangular portion, that is, the entries on and below the
main diagonal In linear algebra, the main diagonal (sometimes principal diagonal, primary diagonal, leading diagonal, major diagonal, or good diagonal) of a matrix A is the list of entries a_ where i = j. All off-diagonal elements are zero in a diagonal matri ...
. For such matrices, the half-vectorization is sometimes more useful than the vectorization. The half-vectorization, vech(''A''), of a symmetric ''n'' × ''n'' matrix ''A'' is the column vector obtained by vectorizing only the lower triangular part of ''A'': :\operatorname(A) = _, \ldots, A_, A_, \ldots, A_, \ldots, A_, A_, A_\mathrm. For example, for the 2×2 matrix A = \begin a & b \\ b & d \end, the half-vectorization is \operatorname(A) = \begin a \\ b \\ d \end. There exist unique matrices transforming the half-vectorization of a matrix to its vectorization and vice versa called, respectively, the
duplication matrix In mathematics, especially in linear algebra and matrix theory, the duplication matrix and the elimination matrix are linear transformations used for transforming half-vectorizations of matrices into vectorizations or (respectively) vice vers ...
and the
elimination matrix In mathematics, especially in linear algebra and matrix theory, the duplication matrix and the elimination matrix are linear transformations used for transforming half-vectorizations of matrices into vectorizations or (respectively) vice vers ...
.


Programming language

Programming languages that implement matrices may have easy means for vectorization. In
Matlab MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementat ...
/
GNU Octave GNU Octave is a high-level programming language primarily intended for scientific computing and numerical computation. Octave helps in solving linear and nonlinear problems numerically, and for performing other numerical experiments using a lan ...
a matrix A can be vectorized by A(:).
GNU Octave GNU Octave is a high-level programming language primarily intended for scientific computing and numerical computation. Octave helps in solving linear and nonlinear problems numerically, and for performing other numerical experiments using a lan ...
also allows vectorization and half-vectorization with vec(A) and vech(A) respectively. Julia has the vec(A) function as well. In Python NumPy arrays implement the flatten method, while in R the desired effect can be achieved via the c() or as.vector() functions. In R, function vec() of package 'ks' allows vectorization and function vech() implemented in both packages 'ks' and 'sn' allows half-vectorization.


Notes

:1.The identity for row-major vectorization is \operatorname(ABC)=(A \otimes C^\mathrm)\operatorname(B).


See also

* Voigt notation * Packed storage matrix *
Column-major order In computing, row-major order and column-major order are methods for storing multidimensional arrays in linear storage such as random access memory. The difference between the orders lies in which elements of an array are contiguous in memory. In ...
* Matricization


References

*Jan R. Magnus and Heinz Neudecker (1999), ''Matrix Differential Calculus with Applications in Statistics and Econometrics'', 2nd Ed., Wiley. {{isbn, 0-471-98633-X. Linear algebra Matrices