Extreme Optimization >
User's Guide >
Vector and Matrix Library >
Matrix Decompositions >
The Symmetric Eigenvalue Decomposition
Extreme Optimization User's Guide
User's Guide
Up: Matrix Decompositions Next: The Non-Symmetric Eigenvalue Decomposition Previous: The Cholesky Decomposition Contents
The Symmetric Eigenvalue Decomposition
The eigenvalue decomposition of a symmetric matrix expresses the
matrix as the product of an orthogonal matrix, a diagonal matrix,
and the transpose of the orthogonal matrix. The matrix must be
square and symmetric. The symmetric eigenvalue decomposition is
usually written as
A = XLXT,
where X is a square, orthogonal matrix, and L
is a diagonal matrix.
An eigenvalue l and an eigenvector X are values
such that
AX = lX.
There are as many eigenvalues and corresponding eigenvectors as
there are rows or columns in the matrix. A real symmetric matrix
always has real eigenvalues.
In the Extreme Optimization Mathematics Library for
.NET, the symmetric eigenvalue decomposition is implemented by
the
SymmetricEigenvalueDecomposition class.
The
SymmetricEigenvalueDecomposition class represents the
eigenvalue decomposition of a real symmetric matrix. It has two
constructors. The first variant takes a Matrix as
its only parameter.
| C# | Copy Code |
SymmetricMatrix aED = new SymmetricMatrix(4,
new double[]
{
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
}, MatrixTriangleMode.Lower);
SymmetricEigenvalueDecomposition ed = new SymmetricEigenvalueDecomposition(aED); |
| Visual Basic | Copy Code |
Dim aED As SymmetricMatrix = New SymmetricMatrix(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 _
}, MatrixTriangleMode.Lower)
Dim ed As SymmetricEigenvalueDecomposition = _
New SymmetricEigenvalueDecomposition(aED) |
The second constructor has an additional Boolean
parameter that specifies whether the contents of the first
parameter may be destroyed during the calculation of the eigenvalue
decomposition.
| C# | Copy Code |
SymmetricEigenvalueDecomposition ed2 = new SymmetricEigenvalueDecomposition(aED, true); |
| Visual Basic | Copy Code |
Dim ed2 As SymmetricEigenvalueDecomposition = _
New SymmetricEigenvalueDecomposition(aED, True) |
The Decompose
method performs the actual decomposition. This method copies
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 in much less time.
| C# | Copy Code |
GeneralMatrix bED = new GeneralMatrix(4, 2,
new double[] {8.70,-13.35,1.89,-4.14,8.30,2.13,1.61,5.00});
Matrix xED = ed.Solve(bED);
Console.WriteLine("x = {0}", xED);
Console.WriteLine("Inv A = {0}", ed.GetInverse().ToString("F4"));
Console.WriteLine("Det A = {0}", ed.GetDeterminant()); |
| Visual Basic | Copy Code |
Dim bED As GeneralMatrix = New GeneralMatrix(4, 2, _
New Double() {8.7, -13.35, 1.89, -4.14, 8.3, 2.13, 1.61, 5.0})
Dim xED As Matrix = ed.Solve(bED)
Console.WriteLine("x = {0}", xED)
Console.WriteLine("Inv A = {0}", ed.GetInverse().ToString("F4"))
Console.WriteLine("Det A = {0}", ed.GetDeterminant()) |
The
Eigenvalues property returns a GeneralVector
that contains the eigenvalues of the matrix. The
Eigenvectors property returns a GeneralMatrix
whose columns contain the corresponding eigenvectors of the
matrix.
| C# | Copy Code |
Console.WriteLine("L = {0}", ed.Eigenvalues.ToString("F4"));
Console.WriteLine("X = {0}", ed.Eigenvectors.ToString("F4")); |
| Visual Basic | Copy Code |
Console.WriteLine("L = {0}", ed.Eigenvalues.ToString("F4"))
Console.WriteLine("X = {0}", ed.Eigenvectors.ToString("F4")) |
The managed implementation of the symmetric eigenvalue
decomposition is based on the LINPACK routines TRED2 and TQL2. The
native version uses the LAPACK routine DSYEVR.
Up: Matrix Decompositions Next: The Non-Symmetric Eigenvalue Decomposition Previous: The Cholesky Decomposition Contents
Copyright 2004-2008,
Extreme Optimization. All rights reserved.
Extreme Optimization, Complexity made simple, M#, and M
Sharp are trademarks of ExoAnalytics Inc.
Microsoft, Visual C#, Visual Basic, Visual Studio, Visual
Studio.NET, and the Visual Studio Logo are registered trademarks of Microsoft Corporation