\Header{eigen}{Spectral Decomposition of a Matrix}
\alias{La.eigen}{eigen}
\keyword{algebra}{eigen}
\keyword{array}{eigen}
\begin{Description}\relax
Computes eigenvalues and eigenvectors.\end{Description}
\begin{Usage}
\begin{verbatim}
eigen(x, symmetric, only.values = FALSE, EISPACK = FALSE)
La.eigen(x, symmetric, only.values = FALSE,
         method = c("dsyevr", "dsyev"))
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a matrix whose spectral decomposition is to be computed.
\item[\code{symmetric}] if \code{TRUE}, the matrix is assumed to be symmetric
(or Hermitian if complex) and only its lower triangle is used.
If \code{symmetric} is not specified, the matrix is inspected for
symmetry.
\item[\code{only.values}] if \code{TRUE}, only the eigenvalues are computed
and returned, otherwise both eigenvalues and eigenvectors are
returned.
\item[\code{EISPACK}] logical. Should EISPACK be used (for compatibility with
\R{} < 1.7.0)?
\item[\code{method}] The LAPACK routine to use in the real symmetric case.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
These functions use the LAPACK routines DSYEV/DSYEVR,
DGEEV, ZHEEV and ZGEEV, and \code{eigen(EISPACK=TRUE)} provides an
interface to the EISPACK routines \code{RS}, \code{RG}, \code{CH}
and \code{CG}.

If \code{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.

\code{eigen} is preferred to \code{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.)

The LAPACK routine DSYEVR is usually substantially
faster than DSYEV: see
\url{http://www.cs.berkeley.edu/~demmel/DOE2000/Report0100.html}.
Most benefits are seen with an optimized BLAS system.

Using \code{method="dsyevr"} requires IEEE 754 arithmetic.  Should
this not be supported on your platform, \code{method="dsyev"} is
used, with a warning.

Computing the eigenvectors is the slow part for large matrices.\end{Details}
\begin{Value}
The spectral decomposition of \code{x} is returned
as components of a list.
\begin{ldescription}
\item[\code{values}] a vector containing the \eqn{p}{} eigenvalues of \code{x},
sorted in \emph{decreasing} order, according to \code{Mod(values)}
if they are complex.

\item[\code{vectors}] a \eqn{p\times p}{p * p} matrix whose columns contain the
eigenvectors of \code{x}, or \code{NULL} if \code{only.values} is
\code{TRUE}.

For \code{eigen(, symmetric = FALSE, EISPACK =TRUE)}
the choice of length of the
eigenvectors is not defined by EISPACK. In all other cases the
vectors are normalized to unit length.

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).

\end{ldescription}
\end{Value}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{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).
\emph{Matrix Eigensystems Routines -- EISPACK Guide}.
Springer-Verlag Lecture Notes in Computer Science.

Anderson. E. and ten others (1999)
\emph{LAPACK Users' Guide}. Third Edition. SIAM.\\
Available on-line at
\url{http://www.netlib.org/lapack/lug/lapack_lug.html}.\end{References}
\begin{SeeAlso}\relax
\code{\Link{svd}}, a generalization of \code{eigen}; \code{\Link{qr}}, and
\code{\Link{chol}} for related decompositions.

To compute the determinant of a matrix, the \code{\Link{qr}}
decomposition is much more efficient: \code{\Link{det}}.

\code{\Link{capabilities}} to test for IEEE 754 arithmetic.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
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

\end{ExampleCode}
\end{Examples}

