eigenvalues of matrices and pencils
evals=spec(A)
[R,diagevals]=spec(A)
evals=spec(A,B)
[alpha,beta]=spec(A,B)
[alpha,beta,Z]=spec(A,B)
[alpha,beta,Q,Z]=spec(A,B)
:A real or complex square matrix : :B real or complex square matrix with same dimensions as A : :evals real or complex vector, the eigenvalues : :diagevals real or complex diagonal matrix (eigenvalues along the
diagonal)
: :alpha real or complex vector, al./be gives the eigenvalues : :beta real vector, al./be gives the eigenvalues : :R real or complex invertible square matrix, matrix right
eigenvectors.
:
:evals=spec(A) returns in vector evals the eigenvalues. : :[R,diagevals] =spec(A) returns in the diagonal matrix evals the
eigenvalues and in R the right eigenvectors.
:
For big full / sparse matrix, you can use the Arnoldi module.
Matrix eigenvalues computations are based on the Lapack routines
A complex symmetric matrix has conjugate offdiagonal terms and real diagonal terms.
Pencil eigenvalues computations are based on the Lapack routines DGGEV and ZGGEV.
It must be noticed that the type of the output variables, such as evals or R for example, is not necessarily the same as the type of the input matrices A and B. In the following paragraph, we analyse the type of the output variables in the case where one computes the eigenvalues and eigenvectors of one single matrix A.
Real A matrix
- Symetric The eigenvalues and the eigenvectors are real.
- Not symmetric The eigenvalues and eigenvectors are complex.
Complex A matrix
- Symetric The eigenvalues are real but the eigenvectors are complex.
- Not symmetric The eigenvalues and the eigenvectors are complex.
// MATRIX EIGENVALUES
A=`diag`_([1,2,3]);
X=`rand`_(3,3);
A=`inv`_(X)*A*X;
spec(A)
x=`poly`_(0,'x');
pol=`det`_(x*`eye`_()-A)
`roots`_(pol)
[S,X]=`bdiag`_(A);
`clean`_(`inv`_(X)*A*X)
// PENCIL EIGENVALUES
A=`rand`_(3,3);
[al,be,R] = spec(A,`eye`_(A));
al./be
`clean`_(`inv`_(R)*A*R) //displaying the eigenvalues (generic matrix)
A=A+%i*`rand`_(A);
E=`rand`_(A);
`roots`_(`det`_(A-%s*E)) //complex case