Click or drag to resize

SpectralDecompositionGetEigenvalues Method (ComplexMatrix, Boolean)

Computes the eigenvalues of the specified Hermitian complex matrix.

Namespace:  Novacta.Analytics.Advanced
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public static DoubleMatrix GetEigenvalues(
	ComplexMatrix matrix,
	bool lowerTriangularPart
)

Parameters

matrix
Type: Novacta.AnalyticsComplexMatrix
The matrix containing the lower or upper triangular part of the matrix whose eigenvalues must be computed.
lowerTriangularPart
Type: SystemBoolean
true if matrix contains the lower triangular part of the matrix to be decomposed; false if matrix contains its upper triangular part.

Return Value

Type: DoubleMatrix
A column vector containing the eigenvalues of the decomposed matrix, in ascending order.
Exceptions
ExceptionCondition
ArgumentNullExceptionmatrix is null.
ArgumentExceptionmatrix is not square.
Examples

In the following example, the eigenvalues of a matrix are computed.

Computing the eigenvalues of a matrix
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       
// 

See Also