Home
Products
Support
Blog
Resources
Company
NMath Matrix User's Guide
TOC |  Previous |  Next |  Index

7.2 Using the Eigenvalue Classes

The NMath Matrix eigenvalue classes solve symmetric, Hermitian, and nonsymmetric eigenvalue problems.

Constructing Eigenvalue Objects

Instances of the eigenvalue classes are constructed from matrices of the appropriate type. For example, this code creates a FloatSymEigDecomp from a FloatSymmetricMatrix:

FloatMatrix A = new FloatMatrix( "4x4 [ 0 1.73205080756888 0 0
                                        1.73205080756888 0 2 0 
                                        0 2 0 1.73205080756888 
                                        0 0 1.73205080756888 0 ]");
FloatSymmetricMatrix Asym = new FloatSymmetricMatrix( A );
FloatSymEigDecomp eig = new FloatSymEigDecomp( Asym );

Similarly, if A is a DoubleHermitianMatrix, this code creates a DoubleHermitianEigDecomp object from A:

DoubleHermitianEigDecomp eig = new DoubleHermitianEigDecomp( A );

Testing for Goodness

All eigenvalue classes provide an IsGood property that returns true if all the eigenvalues and eigenvectors were successfully computed:

DoubleComplexEigDecomp eig = new DoubleComplexEigDecomp( A );
if ( eig.IsGood )
{
  // Do something here...
}

Retrieving Eigenvalues and Eigenvectors

All eigenvalue classes provide read-only properties and member functions for retrieving eigenvalues and eigenvectors.

For example:

FloatEigDecomp decomp = new FloatEigDecomp( A );
Console.WriteLine( "Eigenvalues = " +
  decomp.EigenValues );
Console.WriteLine( "Left eigenvectors = " +
  decomp.LeftEigenVectors );
Console.WriteLine( "Right eigenvectors = " + 
  decomp.RightEigenVectors );

Retrieving Information About the Original Matrix

Read-only properties are also provided for retrieving information about the original matrix A:

Reusing Eigenvalue Decompositions

An existing eigenvalue object can be reused with another matrix using the Factor() method:

FloatSymEigDecomp eig = new FloatSymEigDecomp( A );
if ( eig.IsGood )
{
  // Do something here...
}

eig.Factor( B );
if ( eig.IsGood )
{
  // Do something here...
}

TOC |  Previous |  Next |  Index

Copyright © 2008 CenterSpace Software, LLC. All rights reserved.
All trademarks and registered trademarks mentioned on this web site are the property of their respective owners.
Contact Webmaster