Results tagged “linear algebra” from Math::GSL : Perl <=> GNU Scientific Library

Matrix Eigenvalues in Perl Don't Get Much Easier

The Matrix subsystem has really grown up in the last few days since the 0.16 release, including easy-to-use methods to calculate Matrix eigenvalues. All kinds of other methods are now available, like
my $det1 = $A->det;      # determinant
my $det2 = abs $A;       # determinant

my $inv = $A->inverse;  
my @eigs = $A->eigenvalues;

my ($eigenvalues, $eigenvectors) = $matrix->eigenpair;
my ($eig1,$eig2) = @$eigenvalues;
my ($u,$v)       = @$eigenvectors;
Compare this new script for calculating eigenvalues and eigenvectors of a nonsymmetric matrix to the old version. Yes, quite an improvement and quite pleasing to the eye now. Note that $A->eigenvalues; returns a list of Math::Complex objects because in general the eigenvalues of a real matrix can be complex. Only if your matrix is symmetric are you guaranteed real eigenvalues.
Screw you, spammers! Clicky Web Analytics