SpectralDecompositionGetEigenvalues Method (ComplexMatrix, Boolean) |
Namespace: Novacta.Analytics.Advanced
public static DoubleMatrix GetEigenvalues( ComplexMatrix matrix, bool lowerTriangularPart )
Exception | Condition |
---|---|
ArgumentNullException | matrix is null. |
ArgumentException | matrix is not square. |
In the following example, the eigenvalues of a matrix are computed.
using System; using Novacta.Analytics.Advanced; using System.Numerics; namespace Novacta.Analytics.CodeExamples.Advanced { public class SpectralDecompositionExample1 { public void Main() { // Create a matrix containing the // lower triangular part of the Hermitian matrix // whose eigenvalues must be computed. var matrix = ComplexMatrix.Dense(2, 2, new Complex[4] { new Complex(1, 0), new Complex(-3, -2), new Complex(5, 4), new Complex(-6, 0) }, StorageOrder.RowMajor); // Set the relevant triangular part. bool lowerTriangularPart = false; // Compute the eigenvalues. var eigenvalues = SpectralDecomposition.GetEigenvalues( matrix, lowerTriangularPart); Console.WriteLine("Matrix whose eigenvalues must be computed:"); Console.WriteLine(ComplexMatrix.Dense(2, 2, new Complex[4] { new Complex( 1, 0), new Complex(-3, -2), new Complex(-3, 2), new Complex(-6, 0) }, StorageOrder.RowMajor)); Console.WriteLine("Matrix eigenvalues:"); Console.WriteLine(eigenvalues); } } } // Executing method Main() produces the following output: // // Matrix whose eigenvalues must be computed: // ( 1, 0) ( -3, -2) // ( -3, 2) ( -6, 0) // // // Matrix eigenvalues: // -7.52493781 // 2.52493781 //