Class SymmetricEigenSolver
Solves for eigenvalues and eigenvectors of 3x3 symmetric matrices. Uses the Symmetric QR Algorithm with Householder tridiagonalization and Wilkinson shift.
Namespace: NWH.Aerodynamics.Airfoils
Assembly: NWH.Aerodynamics.dll
Syntax
public class SymmetricEigenSolver
Remarks
Port of WildMagic5 Wm5SymmetricEigensolverGTE class from geometrictools.com. Implementation based on Algorithm 8.2.3 (Symmetric QR Algorithm) from "Matrix Computations, 2nd edition" by Golub and Van Loan. Decomposes matrix A into Q^TAQ = D where D is diagonal (eigenvalues) and Q is orthogonal (eigenvectors).
Constructors
| Edit this page View SourceSymmetricEigenSolver(int, int)
Creates a new eigensolver for NxN symmetric matrices.
Declaration
public SymmetricEigenSolver(int size, int maxIterations)
Parameters
| Type | Name | Description |
|---|---|---|
| int | size | Matrix dimension (N). Must be greater than 1. |
| int | maxIterations | Maximum number of QR iterations allowed for convergence. |
Remarks
Matrix input is stored in row-major order. Computes orthogonal matrix Q and diagonal matrix D such that Q^TAQ = D, where D contains eigenvalues and Q columns contain eigenvectors.
Fields
| Edit this page View SourceNO_CONVERGENCE
Declaration
public const int NO_CONVERGENCE = 2147483647
Field Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceGetEigenvalue(int)
Declaration
public double GetEigenvalue(int c)
Parameters
| Type | Name | Description |
|---|---|---|
| int | c |
Returns
| Type | Description |
|---|---|
| double |
GetEigenvalues()
Declaration
public double[] GetEigenvalues()
Returns
| Type | Description |
|---|---|
| double[] |
GetEigenvalues(double[])
Retrieves the computed eigenvalues.
Declaration
public void GetEigenvalues(double[] eigenvalues)
Parameters
| Type | Name | Description |
|---|---|---|
| double[] | eigenvalues | Output array to receive eigenvalues. Must have size elements. |
Remarks
If sorting was requested in Solve(), eigenvalues will be returned in sorted order.
GetEigenvector(int)
Declaration
public double[] GetEigenvector(int c)
Parameters
| Type | Name | Description |
|---|---|---|
| int | c |
Returns
| Type | Description |
|---|---|
| double[] |
GetEigenvector(int, double[])
Computes a single eigenvector corresponding to the specified eigenvalue index. More efficient than GetEigenvectors when only a subset of eigenvectors is needed.
Declaration
public void GetEigenvector(int c, double[] eigenvector)
Parameters
| Type | Name | Description |
|---|---|---|
| int | c | Index of the eigenvector to compute (0 to size-1). |
| double[] | eigenvector | Output array to receive the eigenvector. Must have size elements. |
GetEigenvectors()
Declaration
public double[] GetEigenvectors()
Returns
| Type | Description |
|---|---|
| double[] |
GetEigenvectors(double[])
Computes the orthogonal eigenvector matrix Q.
Declaration
public void GetEigenvectors(double[] eigenvectors)
Parameters
| Type | Name | Description |
|---|---|---|
| double[] | eigenvectors | Output array to receive eigenvectors in row-major order. Must have size*size elements. |
Remarks
Each column of the output matrix Q represents an eigenvector. The eigenvectors satisfy Q^TAQ = D where D is the diagonal eigenvalue matrix.
IsRotation()
Declaration
public bool IsRotation()
Returns
| Type | Description |
|---|---|
| bool |
Solve(double[], SortType)
Solves for eigenvalues and eigenvectors of the given symmetric matrix.
Declaration
public int Solve(double[] input, SymmetricEigenSolver.SortType eSort)
Parameters
| Type | Name | Description |
|---|---|---|
| double[] | input | Input matrix in row-major order with size*size elements. |
| SymmetricEigenSolver.SortType | eSort | Sort order for eigenvalues (Decreasing, NoSorting, or Increasing). |
Returns
| Type | Description |
|---|---|
| int | Number of iterations until convergence, or NO_CONVERGENCE if failed to converge. |