Example: Eigenvalues and Eigenvectors of a Symmetric Matrix
The eigenvalues and eigenvectors of a symmetric matrix are computed.
using System;
using Imsl.Math;
public class SymEigenEx1
{
public static void Main(String[] args)
{
double[,] a = {
{1, 1, 1},
{1, 1, 1},
{1, 1, 1}
};
SymEigen eigen = new SymEigen(a);
new PrintMatrix("Eigenvalues").Print(eigen.GetValues());
new PrintMatrix("Eigenvectors").Print(eigen.GetVectors());
}
}
Output
Eigenvalues
0
0 3
1 -3.53439879482695E-16
2 -2.22044604925031E-16
Eigenvectors
0 1 2
0 0.577350269189626 0.816496580927726 0
1 0.577350269189626 -0.408248290463863 -0.707106781186547
2 0.577350269189626 -0.408248290463863 0.707106781186548
Link to C# source.