Vectorization (mathematics)
Encyclopedia
In mathematics
, especially in linear algebra
and matrix theory, the vectorization of a matrix
is a linear transformation
which converts the matrix into a column vector. Specifically, the vectorization of an m×n matrix A, denoted by vec(A), is the mn × 1 column vector obtain by stacking the columns of the matrix A on top of one another:
Here represents the -th element of matrix and the superscript denotes the transpose
. Vectorization expresses the isomorphism
between these vector spaces (of matrices and vectors) in coordinates.
For example, for the 2×2 matrix = , the vectorization is .
to express matrix multiplication
as a linear transformation on matrices. In particular,
for matrices A, B, and C of dimensions k×l, l×m, and m×n. For example, if (the adjoint endomorphism
of the Lie algebra
gl(n,C) of all n×n matrices with complex
entries), then , where is the n×n identity matrix
.
There are two other useful formulations:
from the space of n×n matrices with the Hadamard (entrywise) product to Cn with its Hadamard product:
from the space of n×n matrices with the Frobenius (or Hilbert-Schmidt) inner product to Cn :
where the superscript * denotes the conjugate transpose
.
For example, for the 2×2 matrix A = , the half-vectorization is vech(A) = .
There exist unique matrices transforming the half-vectorization of a matrix to its vectorization and vice-versa called, respectively, the duplication matrix
and the elimination matrix.
In Matlab
/GNU Octave
a matrix
In Python
NumPy arrays implement the 'flatten' method, while in R the desired effect can be achieved via the 'c' or 'as.vector' functions.
Mathematics
Mathematics is the study of quantity, space, structure, and change. Mathematicians seek out patterns and formulate new conjectures. Mathematicians resolve the truth or falsity of conjectures by mathematical proofs, which are arguments sufficient to convince other mathematicians of their validity...
, especially in linear algebra
Linear algebra
Linear algebra is a branch of mathematics that studies vector spaces, also called linear spaces, along with linear functions that input one vector and output another. Such functions are called linear maps and can be represented by matrices if a basis is given. Thus matrix theory is often...
and matrix theory, the vectorization of a matrix
Matrix (mathematics)
In mathematics, a matrix is a rectangular array of numbers, symbols, or expressions. The individual items in a matrix are called its elements or entries. An example of a matrix with six elements isMatrices of the same size can be added or subtracted element by element...
is a linear transformation
Linear transformation
In mathematics, a linear map, linear mapping, linear transformation, or linear operator is a function between two vector spaces that preserves the operations of vector addition and scalar multiplication. As a result, it always maps straight lines to straight lines or 0...
which converts the matrix into a column vector. Specifically, the vectorization of an m×n matrix A, denoted by vec(A), is the mn × 1 column vector obtain by stacking the columns of the matrix A on top of one another:
Here represents the -th element of matrix and the superscript denotes the transpose
Transpose
In linear algebra, the transpose of a matrix A is another matrix AT created by any one of the following equivalent actions:...
. Vectorization expresses the isomorphism
Isomorphism
In abstract algebra, an isomorphism is a mapping between objects that shows a relationship between two properties or operations. If there exists an isomorphism between two structures, the two structures are said to be isomorphic. In a certain sense, isomorphic structures are...
between these vector spaces (of matrices and vectors) in coordinates.
For example, for the 2×2 matrix = , the vectorization is .
Compatibility with Kronecker products
The vectorization is frequently used together with the Kronecker productKronecker product
In mathematics, the Kronecker product, denoted by ⊗, is an operation on two matrices of arbitrary size resulting in a block matrix. It gives the matrix of the tensor product with respect to a standard choice of basis. The Kronecker product should not be confused with the usual matrix...
to express matrix multiplication
Matrix multiplication
In mathematics, matrix multiplication is a binary operation that takes a pair of matrices, and produces another matrix. If A is an n-by-m matrix and B is an m-by-p matrix, the result AB of their multiplication is an n-by-p matrix defined only if the number of columns m of the left matrix A is the...
as a linear transformation on matrices. In particular,
for matrices A, B, and C of dimensions k×l, l×m, and m×n. For example, if (the adjoint endomorphism
Adjoint endomorphism
In mathematics, the adjoint endomorphism or adjoint action is an endomorphism of Lie algebras that plays a fundamental role in the development of the theory of Lie algebras and Lie groups....
of the Lie algebra
Lie algebra
In mathematics, a Lie algebra is an algebraic structure whose main use is in studying geometric objects such as Lie groups and differentiable manifolds. Lie algebras were introduced to study the concept of infinitesimal transformations. The term "Lie algebra" was introduced by Hermann Weyl in the...
gl(n,C) of all n×n matrices with complex
Complex number
A complex number is a number consisting of a real part and an imaginary part. Complex numbers extend the idea of the one-dimensional number line to the two-dimensional complex plane by using the number line for the real part and adding a vertical axis to plot the imaginary part...
entries), then , where is the n×n identity matrix
Identity matrix
In linear algebra, the identity matrix or unit matrix of size n is the n×n square matrix with ones on the main diagonal and zeros elsewhere. It is denoted by In, or simply by I if the size is immaterial or can be trivially determined by the context...
.
There are two other useful formulations:
Compatibility with Hadamard products
Vectorization is an algebra homomorphismAlgebra homomorphism
A homomorphism between two algebras, A and B, over a field K, is a map F:A\rightarrow B such that for all k in K and x,y in A,* F = kF* F = F + F...
from the space of n×n matrices with the Hadamard (entrywise) product to Cn with its Hadamard product:
- vec(A B) = vec(A) vec(B).
Compatibility with inner products
Vectorization is a unitary transformationUnitary transformation
In mathematics, a unitary transformation may be informally defined as a transformation that respects the inner product: the inner product of two vectors before the transformation is equal to their inner product after the transformation....
from the space of n×n matrices with the Frobenius (or Hilbert-Schmidt) inner product to Cn :
- tr(A* B) = vec(A)* vec(B)
where the superscript * denotes the conjugate transpose
Conjugate transpose
In mathematics, the conjugate transpose, Hermitian transpose, Hermitian conjugate, or adjoint matrix of an m-by-n matrix A with complex entries is the n-by-m matrix A* obtained from A by taking the transpose and then taking the complex conjugate of each entry...
.
Half-vectorization
For a symmetric matrix 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 n(n+1)/2 entries on and below the main diagonal. 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 n(n+1)/2 × 1 column vector obtained by vectorizing only the lower triangular part of A:- vech(A) = [ A1,1, ..., Am,1, A2,2, ..., An,2, ..., An-1,n-1,An-1,n, An,n ]T.
For example, for the 2×2 matrix A = , the half-vectorization is vech(A) = .
There exist unique matrices transforming the half-vectorization of a matrix to its vectorization and vice-versa called, respectively, the duplication matrix
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 vice-versa....
and the elimination matrix.
Programming language
Programming languages that implement matrices may have easy means for vectorization.In Matlab
MATLAB
MATLAB is a numerical computing environment and fourth-generation programming language. Developed by MathWorks, MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages,...
/GNU Octave
GNU Octave
GNU Octave is a high-level language, primarily intended for numerical computations. It provides a convenient command-line interface for solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with MATLAB...
a matrix
A
can be vectorized by A(:)
.In Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
NumPy arrays implement the 'flatten' method, while in R the desired effect can be achieved via the 'c' or 'as.vector' functions.