Extreme Optimization™: Complexity made simple.

Numerical Components
for .NET

  • Home
  • Features
    • Math Library
    • Vector and Matrix Library
    • Statistics Library
    • Performance
    • Usability
  • Documentation
    • Introduction
    • Math Library User's Guide
    • Vector and Matrix Library User's Guide
    • Statistics Library User's Guide
    • Reference
  • Resources
    • Downloads
    • QuickStart Samples
    • Sample Applications
    • Frequently Asked Questions
    • Technical Support
  • Blog
  • Order
  • Company
    • About us
    • Testimonials
    • Customers
    • Press Releases
    • Careers
    • Contact us
Introduction
Deployment Guide
Using Parallelism
Expand Mathematics Library User's GuideMathematics Library User's Guide
Expand Vector and Matrix Library User's GuideVector and Matrix Library User's Guide
Expand Statistics Library User's GuideStatistics Library User's Guide
Expand ReferenceReference
  • Home
    • Features
    • Solutions
    • Documentation
    • QuickStart Samples
    • Sample Applications
    • Downloads
    • Technical Support
    • Download trial
    • How to buy
    • Blog
    • Company
    • Resources
  • Documentation
    • Introduction
    • Deployment Guide
    • Using Parallelism
    • Mathematics Library User's Guide
    • Vector and Matrix Library User's Guide
    • Statistics Library User's Guide
    • Reference
  • Vector and Matrix Library User's Guide
    • Vectors
    • Matrices
    • Structured Matrix Types
    • Matrix Decompositions
    • Sparse Vectors and Matrices
    • Complex Linear Algebra
    • Single-Precision Linear Algebra
  • Matrix Decompositions
    • The LU Decomposition
    • The QR Decomposition
    • The Cholesky Decomposition
    • The Eigenvalue Decomposition
    • The Singular Value Decomposition
    • Non-Negative Matrix Factorization
    • Solving Linear Systems
  • The Eigenvalue Decomposition
Collapse image Expand Image Copy image CopyHover image
         




The Eigenvalue Decomposition

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 matrix, the eigenvalues are all real, and the eigenvectors are orthogonal. The decomposition then simplifies to:

A = XLXT,

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 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.

In the Extreme Optimization Mathematics Library for .NET, both the symmetric and the non-symmetric eigenvalue decompositions are implemented by the EigenvalueDecomposition class.

The EigenvalueDecomposition class

The EigenvalueDecomposition class represents the eigenvalue decomposition of a real matrix. 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 parameters:

C#  Copy imageCopy
SymmetricMatrix aED = Matrix.CreateSymmetric(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 = aED.GetEigenvalueDecomposition();
Visual Basic  Copy imageCopy
Dim aED As SymmetricMatrix = 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 _
    }, MatrixTriangleMode.Lower)
Dim ed As SymmetricEigenvalueDecomposition = aED.GetEigenvalueDecomposition()

The second overload takes a Boolean parameter that specifies whether the contents of the matrix may be destroyed during the calculation of the eigenvalue decomposition.

C#  Copy imageCopy
SymmetricEigenvalueDecomposition ed2 = aED.GetEigenvalueDecomposition(true);
Visual Basic  Copy imageCopy
Dim ed2 As SymmetricEigenvalueDecomposition = aED.GetEigenvalueDecomposition(True)

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 in much less time. However, unlike other decompositions, the non-symmetric eigenvalue decomposition does not give an advantage when solving equations or computing the inverse. For these methods, the EigenvalueDecomposition class simply defers to corresponding method of the base matrix.

C#  Copy imageCopy
DenseMatrix bED = Matrix.Create(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 imageCopy
Dim bED As DenseMatrix = Matrix.Create(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 ComplexEigenvalues property returns a ComplexVector that contains the eigenvalues of the matrix. This is a complex vector because the eigenvalues may be complex. The ComplexEigenvectors property returns a ComplexMatrix whose columns contain the corresponding eigenvectors of the matrix.

The RealEigenvalues property returns a Vector that contains only the real eigenvalues of the matrix. The RealEigenvectors property returns a Matrix whose columns contain only the eigenvectors corresponding to the real eigenvalues of the matrix.

For a symmetric matrix, all eigenvalues and eigenvectors are always real:

C#  Copy imageCopy
Console.WriteLine("L = {0}", ed.Eigenvalues.ToString("F4"));
Console.WriteLine("X = {0}", ed.Eigenvectors.ToString("F4"));
Visual Basic  Copy imageCopy
Console.WriteLine("L = {0}", ed.Eigenvalues.ToString("F4"))
Console.WriteLine("X = {0}", ed.Eigenvectors.ToString("F4"))

For a non-symmetric matrix, complex eigenvalues and eigenvectors may occur in complex conjugate pairs. In this case, they are omitted from the values returned by the RealEigenvalues and RealEigenvectors properties.

The RawEigenvectors property returns a DenseMatrix 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 components of the corresponding eigenvectors.

C#  Copy imageCopy
Console.WriteLine("L = {0}", ed.Eigenvalues.ToString("F4"));
Console.WriteLine("X = {0}", ed.Eigenvectors.ToString("F4"));
Console.WriteLine("L(real) = {0}", ed.RealEigenvalues.ToString("F4"));
Console.WriteLine("X(real) = {0}", ed.RealEigenvectors.ToString("F4"));
Console.WriteLine("X(raw) = {0}", ed.RawEigenvectors.ToString("F4"));
Visual Basic  Copy imageCopy
Console.WriteLine("L = {0}", ed.Eigenvalues.ToString("F4"))
Console.WriteLine("X = {0}", ed.Eigenvectors.ToString("F4"))
Console.WriteLine("L(real) = {0}", ed.RealEigenvalues.ToString("F4"))
Console.WriteLine("X(real) = {0}", ed.RealEigenvectors.ToString("F4"))
Console.WriteLine("X(raw) = {0}", ed.RawEigenvectors.ToString("F4"))

The managed implementation of the symmetric eigenvalue decomposition is based on the LINPACK routines TRED2 and TQL2. The non-symmetric eigenvalue decomposition is based on the LINPACK routines ELMHES and HQR2. The native version uses the LAPACK routine DSYEVR for the symmetric case and DGEEV for the non-symmetric case.

Send comments on this topic to support@extremeoptimization.com

Copyright (c) 2004-2011 ExoAnalytics Inc.

Copyright © 2003-2013, 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 Optimized for Visual Studio logo
are registered trademarks of Microsoft Corporation.