Math::MatrixDecomposition::Eigen - eigenvalues and eigenvectors
Object-oriented interface.
use Math::MatrixDecomposition::Eigen; $eigen = Math::MatrixDecomposition::Eigen->new; $eigen->decompose ($A = [...]); # Decomposition is the default action for 'new'. # This one-liner is equivalent to the command sequence above. $eigen = Math::MatrixDecomposition::Eigen->new ($A = [...]);
The procedural form is even shorter.
use Math::MatrixDecomposition qw(eig); $eigen = eig ($A = [...]);
eig
The eig function is the short form of Math::MatrixDecomposition::Eigen->new (which see). The eig function has to be used as a subroutine. It is not exported by default.
Math::MatrixDecomposition::Eigen->new
new
Create a new object. Any arguments are forwarded to the decompose method (which see). The new constructor can be used as a class or instance method.
decompose
Calculate eigenvalues and eigenvectors of a real matrix.
First argument a is an array reference to the matrix elements. Matrix elements are interpreted in row-major layout.
Optional second argument m is the number of matrix rows. If omitted, it is assumed that the matrix is square.
Optional third argument n is the number of matrix columns. If omitted, the number of matrix columns is calculated automatically.
Remaining arguments are property/value pairs with the following meaning.
balance
Whether or not to balance a non-symmetric matrix a. Default is true.
normalize
Whether or not to normalize the eigenvectors. Default is true.
positive
Whether or not to make the first non-zero element of an eigenvector a positive number. Default is true.
Return value is the eigenvalue/eigenvector object.
Normalize the eigenvectors.
sort
Sort eigenvalues and corresponding eigenvectors or vice versa.
Argument order is the sorting order (a string). The possible values for order together with their meaning is described in the following table.
"abs_desc"
Sort eigenvalues in descending order by first comparing the absolute value of the real part, then the absolute value, then the real part, and finally the imaginary part.
"abs_asc"
Sort eigenvalues in ascending order. This is the reverse order of "abs_desc".
"norm_desc"
Sort eigenvalues in descending order by first comparing the absolute value, then the real part, and finally the imaginary part. If all eigenvalues are real, this sorting order is equal to "abs_desc".
"norm_asc"
Sort eigenvalues in ascending order. This is the reverse order of "norm_desc". If all eigenvalues are real, this sorting order is equal to "abs_asc".
"desc"
Sort eigenvalues in descending order by first comparing the real part and then the imaginary part.
"asc"
Sort eigenvalues in ascending order. This is the reverse order of "desc".
"vec_desc"
Sort eigenvectors in descending order.
"vec_asc"
Sort eigenvectors in ascending order.
value
values
Return one or more eigenvalues.
Arguments are one or more indices. If no argument is specified, return all eigenvalues as a list.
If $eigen is a eigenvalues/eigenvectors object, the following expressions are valid use cases of the value/values method.
$eigen
# Get all eigenvalues. @all = $eigen->values; # Get a single eigenvalue. $first = $eigen->value (0); # Get multiple eigenvalues. ($first, $last) = $eigen->values (0, -1);
Complex eigenvalues are Math::Complex objects.
vector
vectors
Return one or more eigenvectors.
Arguments are one or more indices. If no argument is specified, return all eigenvectors as a list.
If $eigen is a eigenvalues/eigenvectors object, the following expressions are valid use cases of the vector/vectors method.
# Get all eigenvectors. @all = $eigen->vectors; # Get a single eigenvector. $first = $eigen->vector (0); # Get multiple eigenvectors. ($first, $last) = $eigen->vectors (0, -1);
An eigenvector is a Perl array reference. If you modify the elements of an eigenvector, you modify the elements of the original eigenvector.
Math::MatrixDecomposition
Wikipedia, http://en.wikipedia.org/wiki/Eigenvalue, http://en.wikipedia.org/wiki/Eigendecomposition_of_a_matrix
MathWorld, http://mathworld.wolfram.com/Eigenvalue.html, http://mathworld.wolfram.com/EigenDecomposition.html
Ralph Schleicher <ralph@cpan.org>
To install Math::MatrixDecomposition, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::MatrixDecomposition
CPAN shell
perl -MCPAN -e shell install Math::MatrixDecomposition
For more information on module installation, please visit the detailed CPAN module installation guide.