eigen {base} | R Documentation |
Spectral Decomposition of a Matrix
Description
Computes eigenvalues and eigenvectors.
Usage
eigen(x, symmetric, only.values = FALSE, EISPACK = FALSE)
Arguments
x |
a matrix whose spectral decomposition is to be computed. |
symmetric |
if |
only.values |
if |
EISPACK |
logical. Should EISPACK be used (for compatibility with R < 1.7.0)? |
Details
By default eigen
uses the LAPACK routines DSYEVR/DSYEV,
DGEEV, ZHEEV and ZGEEV whereas eigen(EISPACK=TRUE)
provides an
interface to the EISPACK routines RS
, RG
, CH
and CG
.
If symmetric
is unspecified, the code attempts to
determine if the matrix is symmetric up to plausible numerical
inaccuracies. It is faster and surer to set the value yourself.
eigen
is preferred to eigen(EISPACK = TRUE)
for new projects, but its eigenvectors may differ in sign and
(in the asymmetric case) in normalization. (They may also differ
between methods and between platforms.)
In the real symmetric case, LAPACK routine DSYEVR is used which requires IEEE 754 arithmetic. Should this not be supported on your platform, DSYEV is used, with a warning.
Computing the eigenvectors is the slow part for large matrices.
Value
The spectral decomposition of x
is returned as components of a
list with components
values |
a vector containing the |
vectors |
either a For Recall that the eigenvectors are only defined up to a constant: even when the length is specified they are still only defined up to a scalar of modulus one (the sign for real matrices). |
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth \& Brooks/Cole.
Smith, B. T, Boyle, J. M., Dongarra, J. J., Garbow, B. S., Ikebe,Y., Klema, V., and Moler, C. B. (1976). Matrix Eigensystems Routines – EISPACK Guide. Springer-Verlag Lecture Notes in Computer Science.
Anderson. E. and ten others (1999)
LAPACK Users' Guide. Third Edition. SIAM.
Available on-line at
http://www.netlib.org/lapack/lug/lapack_lug.html.
See Also
svd
, a generalization of eigen
; qr
, and
chol
for related decompositions.
To compute the determinant of a matrix, the qr
decomposition is much more efficient: det
.
capabilities
to test for IEEE 754 arithmetic.
Examples
eigen(cbind(c(1,-1),c(-1,1)))
eigen(cbind(c(1,-1),c(-1,1)), symmetric = FALSE)# same (different algorithm).
eigen(cbind(1,c(1,-1)), only.values = TRUE)
eigen(cbind(-1,2:1)) # complex values
eigen(print(cbind(c(0,1i), c(-1i,0))))# Hermite ==> real Eigen values
## 3 x 3:
eigen(cbind( 1,3:1,1:3))
eigen(cbind(-1,c(1:2,0),0:2)) # complex values