CodePlexProject Hosting for Open Source Software

Many applications of matrix algebra result in eigen-problems. An eigen-problem gives us a matrix A and asks us to find vectors v such that A v = e v, that is vectors v that, when multiplied by the matrix A, do not produce some entirely
new vector but instead merely scale by some number e. v is called an eigenvector of A and e its eigenvalue. In general, and N-dimensional square matrix will have N eigenvectors. For a generic square matrix, the eigenvalue and eigenvector components can be
complex, but for symmetric matrices they are guaranteed to be real.

Meta.Numerics can solve eigen-problems for both symmetric and general square matrices. The solutions to eigen-problems are packaged as instances of the RealEigensystem or ComplexEigensystem classes, which can be queried for eigenvectors and eigenvalues.

For example, the following code gets the eigenvalues and eigenvectors of a symmetric matrix S.

It often occurs that you actually only require the eigenvalues of a matrix, and don't care about the eigenvectors. In that case, it's more efficient to not ask Meta.Numerics for the whole eigensystem solution, but just for the eigenvalue:

Meta.Numerics can solve eigen-problems for both symmetric and general square matrices. The solutions to eigen-problems are packaged as instances of the RealEigensystem or ComplexEigensystem classes, which can be queried for eigenvectors and eigenvalues.

For example, the following code gets the eigenvalues and eigenvectors of a symmetric matrix S.

// Define a symmetric matrix; note only half the entries need to be specified explicitly SymmetricMatrix S = new SymmetricMatrix(3); S[0,0] = 0.0; S[0,1] = 1.0; S[0,2] = 2.0; S[1,1] = 2.0; S[1,2] = 3.0; S[2,2] = 4.0; // Find scalar a and vector v such that A v = a v RealEigensystem E = S.Eigensystem(); // Process all the eigenvectors and eigenvalues found for (int i = 0; i < E.Dimension; i++) { ColumnVector v = E.Eigenvector(i); double e = E.Eigenvalue(i); // now do something with these }

It often occurs that you actually only require the eigenvalues of a matrix, and don't care about the eigenvectors. In that case, it's more efficient to not ask Meta.Numerics for the whole eigensystem solution, but just for the eigenvalue:

// Just the eigenvalues, please double[] eigenvalues = S.Eigenvalues();

Last edited Apr 2, 2011 at 12:48 AM by ichbin, version 2