ack has asked for the wisdom of the Perl Monks concerning the following question:

Brother and sister monks; I have an application that needs to compute the eigenvalues and eigenvectors for square, non-symmetric matrices.

I have looked all over CPAN and have found several nice pacages (e.g., in the Math:: section, Statistics:: section, etc.). But all require symmetric matrices (which mine are not).

I have found a couple of nice applets out on the net that can do the job and I can do the calculations in the R language. But I need to be able to do it in Perl so that I can fold it into a larger Perl application that I'm developing for use at work.

Does anyone in the Monestary know of a Perl package that can compute eigenvalues and eigenvectors for non-symmetric square matrices?

ack Albuquerque, NM
  • Comment on Egenvalues/Eigenvectors for Non-Symmetric Arrays?

Replies are listed 'Best First'.
Re: Egenvalues/Eigenvectors for Non-Symmetric Arrays?
by Corion (Patriarch) on Jun 16, 2009 at 14:50 UTC

    Eigen returns at least Math::GSL::Eigen, which has functions for eigenvalues of both symmetric and nonsymmetric matrices. I'm not sure where you've looked or why GSL was inappropriate. PDL::MatrixOps also discusses an eigens function which computes the eigenvalues and vectors using PDL (I guess).

      I just took a look at Math::GSL::Eigen, installed it and tested it; looks like it'll do the job. I don't know why I missed it either.

      I had done several searches on CPAN and Super Searches here in the Monestary but came up empty except for 2 or 3 packages that all, according to their documentation, only worked with symmetric matrices. I actually tried several using known test matrices and they all failed on all but the symmetric matrices.

      But I never came up with Math::GSL::Eigen...don't know why. Maybe I didn't phrase my search question quite right.

      When I just went out a couple of minutes ago and checked it out with Perl Package Manager I realized that I probably was scared off thinking I need to install the GNU package, too. I think perhaps I didn't overlook Math::GSL::Eigen; just thought I didn't have all that was required to use it. I should've known better.

      Anyway, thank you so much for the pointer. Somehow I just knew that someone had to have done this. Your pointer is so very much appreciated.

      ack Albuquerque, NM
        If the matricies are very large and sparse, you may be better off using a sparse format and using something like power method. This may also be a good job for a little inline C.
Re: Egenvalues/Eigenvectors for Non-Symmetric Arrays?
by tmaly (Monk) on Jun 16, 2009 at 22:23 UTC

    If you wanted to keep that part in R, you could use the R to perl bridge RSPerl http://www.omegahat.org/RSPerl/

    I have used it before to do kernel density estimations and it works quite well