The NMath Matrix eigenvalue classes solve symmetric, Hermitian, and nonsymmetric eigenvalue problems.
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 );
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... }
All eigenvalue classes provide read-only properties and member functions for retrieving eigenvalues and eigenvectors.
FloatEigDecomp decomp = new FloatEigDecomp( A ); Console.WriteLine( "Eigenvalues = " + decomp.EigenValues ); Console.WriteLine( "Left eigenvectors = " + decomp.LeftEigenVectors ); Console.WriteLine( "Right eigenvectors = " + decomp.RightEigenVectors );
Read-only properties are also provided for retrieving information about the original matrix A:
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