Extreme Optimization™: Complexity made simple.

Math and Statistics
Libraries 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
    • Data Analysis 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
    • Partners
    • Contact us
Introduction
Deployment Guide
Nuget packages
Configuration
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 Data Analysis Library User's GuideData Analysis Library User's Guide
Expand Statistics Library User's GuideStatistics Library User's Guide
Expand Data Access Library User's GuideData Access Library User's Guide
Expand ReferenceReference
  • Extreme Optimization
    • Features
    • Solutions
    • Documentation
    • QuickStart Samples
    • Sample Applications
    • Downloads
    • Technical Support
    • Download trial
    • How to buy
    • Blog
    • Company
    • Resources
  • Documentation
    • Introduction
    • Deployment Guide
    • Nuget packages
    • Configuration
    • Using Parallelism
    • Mathematics Library User's Guide
    • Vector and Matrix Library User's Guide
    • Data Analysis Library User's Guide
    • Statistics Library User's Guide
    • Data Access Library User's Guide
    • Reference
  • Vector and Matrix Library User's Guide
    • Basic Concepts
    • Vectors
    • Matrices
    • Structured Matrix Types
    • Matrix Decompositions
    • Sparse Vectors and Matrices
    • Complex Linear Algebra
    • Single-Precision Linear Algebra
    • Distributed and GPU Computing
  • Matrix Decompositions
    • The LU Decomposition
    • The QR Decomposition
    • The Cholesky Decomposition
    • The Symmetric Indefinite Decomposition
    • The Eigenvalue Decomposition
    • The Generalized Eigenvalue Decomposition
    • The Singular Value Decomposition
    • The Generalized Singular Value Decomposition
    • Non-Negative Matrix Factorization
    • Solving Linear Systems
  • The Generalized Eigenvalue Decomposition

The Generalized Eigenvalue Decomposition

Extreme Optimization Numerical Libraries for .NET Professional

The generalized eigenvalue decomposition of a pair of square matrices computes scalars λ, μ and vectors x, y, such that

Ax = λBx ,

and

μAy = By ,

When λ and μ are not both zero, then the two problems are equivalent with x = y and μ = 1/λ. To cover all cases, a generalized eigenvalue decomposition returns two values whose quotient, if it exists, is equal to the eigenvalue.

The values λ and μ are eigenvalues and the vectors x and y are eigenvectors.

The case where A and B are both symmetric or Hermitian and B is also positive definite is special. In this case, all eigenvalues are real and the eigenvectors are orthogonal with respect to B. That is, if X is the matrix whose columns are the eigenvectors, and I is the identity matrix, then (for real matrices)

XTBX = I.

When B is the identity matrix, then the generalized eigenvalue decomposition reduces to the standard eigenvalue decomposition.

There are as many eigenvalues and corresponding eigenvectors as there are rows or columns in the matrices. 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 Generalized Eigenvalue Decompositions

All variations of eigenvalue decompositions (real symmetric and non-symmetric, complex Hermitian and non-Hermitian) are represented by the GeneralizedEigenvalueDecompositionT class. It has no constructors. Instead, it is created by calling the GetEigenvalueDecomposition method on the primary matrix (A). This method has two overloads. The first overload has one argument: the secondary matrix (B). Both matrices must be square. The second overload takes an additional Boolean argument that specifies whether the contents of the matrices may be destroyed during the calculation of the eigenvalue decomposition.

C#
VB
C++
F#
Copy
var A = Matrix.CreateSymmetric(3, new double[]
    { 1,2,3, 2,4,9, 3,9,15 },
    MatrixTriangle.Upper, MatrixElementOrder.ColumnMajor);
var B = Matrix.CreateSymmetric(3, new double[]
    { 3,-2,3, -2,6,-9, 3,-9,17 },
    MatrixTriangle.Upper, MatrixElementOrder.ColumnMajor);
var geig = A.GetEigenvalueDecomposition(B);
Dim A = Matrix.CreateSymmetric(3, New Double() {
    1, 2, 3, 2, 4, 9, 3, 9, 15},
    MatrixTriangle.Upper, MatrixElementOrder.ColumnMajor)
Dim B = Matrix.CreateSymmetric(3, New Double() {
    3, -2, 3, -2, 6, -9, 3, -9, 17},
    MatrixTriangle.Upper, MatrixElementOrder.ColumnMajor)
Dim geig = A.GetEigenvalueDecomposition(B)

No code example is currently available or this language may not be supported.

let A = Matrix.CreateSymmetric(3, 
            [| 1;2;3; 2;4;9; 3;9;15 |],
            MatrixTriangle.Upper, MatrixElementOrder.ColumnMajor)
let B = Matrix.CreateSymmetric(3, 
            [| 3;-2;3; -2;6;-9; 3;-9;17 |],
            MatrixTriangle.Upper, MatrixElementOrder.ColumnMajor)
let geig = A.GetEigenvalueDecomposition(B)

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.

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.

Real matrices

For symmetric matrices where the secondary matrix is positive definite, 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:

C#
VB
C++
F#
Copy
var L = geig.Eigenvalues;
var X = geig.Eigenvectors;
Dim L = geig.Eigenvalues
Dim X = geig.Eigenvectors

No code example is currently available or this language may not be supported.

let L = geig.Eigenvalues
let X = geig.Eigenvectors

Otherwise, there may be 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.

C#
VB
C++
F#
Copy
var A = Matrix.Create(4, 4, new double[] {
        3.9,   4.3,   4.3,  4.4,
        12.5,  21.5,  21.5, 26.0,
        -34.5, -47.5, -43.5,-46.0,
        -0.5,  7.5,   3.5,  6.0 }, 
    MatrixElementOrder.ColumnMajor);
var B = Matrix.Create(4, 4, new double[] {
    1.0, 1.0, 1.0, 1.0,
    2.0, 3.0, 3.0, 3.0,
    -3.0, -5.0, -4.0, -4.0,
    1.0, 4.0, 3.0, 4.0 },
    MatrixElementOrder.ColumnMajor);
var geig = A.GetEigenvalueDecomposition(B);

var L = geig.Eigenvalues;
var X = geig.Eigenvectors;
var complexL = geig.ComplexEigenvalues;
var complexX = geig.ComplexEigenvectors;
var rawX = geig.RawEigenvectors;
Dim A = Matrix.Create(4, 4, New Double() {
        3.9, 4.3, 4.3, 4.4,
        12.5, 21.5, 21.5, 26.0,
        -34.5, -47.5, -43.5, -46.0,
        -0.5, 7.5, 3.5, 6.0},
    MatrixElementOrder.ColumnMajor)
Dim B = Matrix.Create(4, 4, New Double() {
        1.0, 1.0, 1.0, 1.0,
        2.0, 3.0, 3.0, 3.0,
        -3.0, -5.0, -4.0, -4.0,
        1.0, 4.0, 3.0, 4.0},
        MatrixElementOrder.ColumnMajor)
Dim geig = A.GetEigenvalueDecomposition(B)

Dim L = geig.Eigenvalues
Dim X = geig.Eigenvectors
Dim complexL = geig.ComplexEigenvalues
Dim complexX = geig.ComplexEigenvectors
Dim rawX = geig.RawEigenvectors

No code example is currently available or this language may not be supported.

let A = Matrix.Create(4, 4, 
          [|
            3.9;   4.3;   4.3;  4.4;
            12.5;  21.5;  21.5; 26.0;
            -34.5; -47.5; -43.5;-46.0;
            -0.5;  7.5;   3.5;  6.0 
          |], MatrixElementOrder.ColumnMajor)
let B = Matrix.Create(4, 4,
          [|
            1.0; 1.0; 1.0; 1.0;
            2.0; 3.0; 3.0; 3.0;
            -3.0; -5.0; -4.0; -4.0;
            1.0; 4.0; 3.0; 4.0 
          |], MatrixElementOrder.ColumnMajor)
let geig = A.GetEigenvalueDecomposition(B)

let L = geig.Eigenvalues
let X = geig.Eigenvectors
let complexL = geig.ComplexEigenvalues
let complexX = geig.ComplexEigenvectors
let rawX = geig.RawEigenvectors
Complex matrices

The generalized eigenvalues and eigenvalues of a pair of complex matrices 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 generalized eigenvalues of a pair of Hermitian matrices where the secondary matrix is also positive definite, are also 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.

Singular secondary matrices

If the secondary matrix B is singular, then one or more of the generalized eigenvalues of the pair is infinite. The generalized eigenvalues can also be returned as pairs whose quotient is the generalized eigenvalue. When the denominator of the quotient is zero, the generalized eigenvalue is infinite.

Three properties give access to the quotient form of the generalized eigenvalues. The EigenvalueDenominators property returns a vector containing the denominators of the quotients. For real matrices, it is always real. The EigenvalueNumerators property returns a vector containing the numerators of the quotients. As with the generalized eigenvalues themselves, this property only returns real numerators for real matrices. To access the the full set of numerators, use the ComplexEigenvalueNumerators property.

Copyright (c) 2004-2021 ExoAnalytics Inc.

Send comments on this topic to support@extremeoptimization.com

Copyright © 2004-2021, 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.