The eigenvalue decomposition of a square matrix writes the matrix as a product of
matrices:
A = XΛX-1,
where X is a square matrix, and Λ is a diagonal matrix. In the
case of a symmetric or Hermitian matrix, the eigenvalues are all real,
and the eigenvectors are orthogonal or unitary.
The decomposition then simplifies to:
A = XLXT,
for real matrices, and
A = XLXH,
For complex matrices. An eigenvalue λ and an eigenvector
X are values such that
AX = λX.
There are as many eigenvalues and corresponding eigenvectors
as there are rows or columns in the matrix. However,
the eigenvalues and eigenvectors of a real matrix need not be real.
In this case, they come in complex conjugate pairs.
The eigenvalues and eigenvectors of a real symmetric matrix are always real.
Working with Eigenvalue Decompositions
All variations of eigenvalue decompositions (symmetric and non-symmetric, real and complex)
are represented by the
EigenvalueDecompositionT class.
It has no constructors. Instead, it is created by calling
the GetEigenvalueDecomposition
method on the matrix. This method has two overloads. The first overload has no arguments:
The second overload takes a Boolean argument
that specifies whether the contents of the matrix may be destroyed
during the calculation of the eigenvalue decomposition.
var A = Matrix.CreateSymmetric(4, new[] {
4.16,-3.12, 0.56,-0.10,
0, 5.03,-0.83, 1.18,
0,0, 0.76, 0.34,
0,0,0, 1.18 },
MatrixTriangle.Upper, MatrixElementOrder.RowMajor);
var eig = A.GetEigenvalueDecomposition();
Dim A = Matrix.CreateSymmetric(4, New Double() {
4.16, -3.12, 0.56, -0.1,
0, 5.03, -0.83, 1.18,
0, 0, 0.76, 0.34,
0, 0, 0, 1.18},
MatrixTriangle.Upper, MatrixElementOrder.RowMajor)
Dim eig = A.GetEigenvalueDecomposition()
No code example is currently available or this language may not be supported.
let A = Matrix.CreateSymmetric(4,
[|
4.16;-3.12; 0.56;-0.10;
0.00; 5.03;-0.83; 1.18;
0.00; 0.00; 0.76; 0.34;
0.00; 0.00; 0.00; 1.18
|], MatrixTriangle.Upper, MatrixElementOrder.RowMajor)
let eig = A.GetEigenvalueDecomposition()
The Decompose method performs the
actual decomposition. This method makes a copy of the matrix if necessary. It then calls the appropriate LAPACK routine
to perform the actual decomposition. This method is called by other methods as needed. You will rarely need to call
it explicitly.
Once the decomposition is computed, a number of operations can be performed.
However, unlike other decompositions, eigenvalue decompositions generally don't give
an advantage when solving equations or computing the inverse. For these methods,
the EigenvalueDecompositionT
class simply defers to corresponding method of the base matrix.
var b = Matrix.Create(4, 2, new double[] {
8.70, -13.35, 1.89, -4.14,
8.30, 2.13, 1.61, 5.00 }, MatrixElementOrder.ColumnMajor);
var x = eig.Solve(b);
var invA = eig.GetInverse();
var detA = eig.GetDeterminant();
Dim b = Matrix.Create(4, 2, New Double() {
8.7, -13.35, 1.89, -4.14,
8.3, 2.13, 1.61, 5.0}, MatrixElementOrder.ColumnMajor)
Dim x0 = eig.Solve(b)
Dim invA = eig.GetInverse()
Dim detA = eig.GetDeterminant()
No code example is currently available or this language may not be supported.
let b = Matrix.Create(4, 2,
[|
8.70; -13.35; 1.89; -4.14;
8.30; 2.13; 1.61; 5.00
|], MatrixElementOrder.ColumnMajor)
let x = eig.Solve(b)
let invA = eig.GetInverse()
let detA = eig.GetDeterminant()
Working with Eigenvalues and Eigenvectors
Because real matrices may have complex eigenvalues and eigenvectors,
the eigenvalue decomposition of a real matrix deserves some special attention.
For a symmetric matrix, all eigenvalues and eigenvectors are always real.
The Eigenvalues
property returns a vector containing the eigenvalues.
The Eigenvectors
property returns a matrix that has the corresponding eigenvectors as its columns:
var L = eig.Eigenvalues;
var X = eig.Eigenvectors;
Dim L = eig.Eigenvalues
Dim X = eig.Eigenvectors
No code example is currently available or this language may not be supported.
let L = eig.Eigenvalues
let X = eig.Eigenvectors
A non-symmetric real matrix may have complex eigenvalues, which occur in complex
conjugate pairs. The corresponding eigenvectors are also complex and also come in
complex conjugate pairs.
The Eigenvalues
and Eigenvectors
return only the real eigenvalues and eigenvectors.
To get all eigenvalues and eigenvectors, use the
ComplexEigenvalues
and ComplexEigenvectors
properties.
The RawEigenvectors
property returns a matrix whose columns
contain all the information about the eigenvectors. For real eigenvalues, the corresponding column contains the
corresponding eigenvector. For complex eigenvalues, which always occur in complex conjugate pairs, two adjoining
columns contain the real and imaginary elements of the corresponding eigenvectors.
var A = Matrix.Create(4, 4, new double[] {
0.35, 0.09, -0.44, 0.25,
0.45, 0.07, -0.33, -0.32,
-0.14, -0.54, -0.03, -0.13,
-0.17, 0.35, 0.17, 0.11}, MatrixElementOrder.ColumnMajor);
var eig = A.GetEigenvalueDecomposition();
var L = eig.Eigenvalues;
var X = eig.Eigenvectors;
var complexL = eig.ComplexEigenvalues;
var complexX = eig.ComplexEigenvectors;
var rawX = eig.RawEigenvectors;
Dim A = Matrix.Create(4, 4, New Double() {
0.35, 0.09, -0.44, 0.25,
0.45, 0.07, -0.33, -0.32,
-0.14, -0.54, -0.03, -0.13,
-0.17, 0.35, 0.17, 0.11}, MatrixElementOrder.ColumnMajor)
Dim eig = A.GetEigenvalueDecomposition()
Dim L = eig.Eigenvalues
Dim X = eig.Eigenvectors
Dim complexL = eig.ComplexEigenvalues
Dim complexX = eig.ComplexEigenvectors
Dim rawX = eig.RawEigenvectors
No code example is currently available or this language may not be supported.
let A = Matrix.Create(4, 4,
[|
0.35; 0.09; -0.44; 0.25;
0.45; 0.07; -0.33; -0.32;
-0.14; -0.54; -0.03; -0.13;
-0.17; 0.35; 0.17; 0.11
|], MatrixElementOrder.ColumnMajor)
let eig = A.GetEigenvalueDecomposition()
let L = eig.Eigenvalues
let X = eig.Eigenvectors
let complexL = eig.ComplexEigenvalues
let complexX = eig.ComplexEigenvectors
let rawX = eig.RawEigenvectors
The eigenvalues and eigenvalues of a complex matrix are also complex.
The Eigenvalues
property returns a vector containing the eigenvalues.
The Eigenvectors
property returns a matrix that has the corresponding eigenvectors as its columns.
The eigenvalues of a Hermitian matrix are real. This simply means that the imaginary
component of the eigenvalue vector is identically zero.
The ComplexEigenvalues,
ComplexEigenvectors,
and RawEigenvectors
properties are meaningless for complex eigenvalue decompositions.