EVOLUTION-MANAGER
Edit File: eigen.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Spectral Decomposition of a Matrix</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for eigen {base}"><tr><td>eigen {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Spectral Decomposition of a Matrix</h2> <h3>Description</h3> <p>Computes eigenvalues and eigenvectors of numeric (double, integer, logical) or complex matrices. </p> <h3>Usage</h3> <pre> eigen(x, symmetric, only.values = FALSE, EISPACK = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a numeric or complex matrix whose spectral decomposition is to be computed. Logical matrices are coerced to numeric.</p> </td></tr> <tr valign="top"><td><code>symmetric</code></td> <td> <p>if <code>TRUE</code>, the matrix is assumed to be symmetric (or Hermitian if complex) and only its lower triangle (diagonal included) is used. If <code>symmetric</code> is not specified, <code><a href="isSymmetric.html">isSymmetric</a>(x)</code> is used.</p> </td></tr> <tr valign="top"><td><code>only.values</code></td> <td> <p>if <code>TRUE</code>, only the eigenvalues are computed and returned, otherwise both eigenvalues and eigenvectors are returned.</p> </td></tr> <tr valign="top"><td><code>EISPACK</code></td> <td> <p>logical. Defunct and ignored.</p> </td></tr> </table> <h3>Details</h3> <p>If <code>symmetric</code> is unspecified, <code><a href="isSymmetric.html">isSymmetric</a>(x)</code> determines if the matrix is symmetric up to plausible numerical inaccuracies. It is surer and typically much faster to set the value yourself. </p> <p>Computing the eigenvectors is the slow part for large matrices. </p> <p>Computing the eigendecomposition of a matrix is subject to errors on a real-world computer: the definitive analysis is Wilkinson (1965). All you can hope for is a solution to a problem suitably close to <code>x</code>. So even though a real asymmetric <code>x</code> may have an algebraic solution with repeated real eigenvalues, the computed solution may be of a similar matrix with complex conjugate pairs of eigenvalues. </p> <p>Unsuccessful results from the underlying LAPACK code will result in an error giving a positive error code (most often <code>1</code>): these can only be interpreted by detailed study of the FORTRAN code. </p> <h3>Value</h3> <p>The spectral decomposition of <code>x</code> is returned as a list with components </p> <table summary="R valueblock"> <tr valign="top"><td><code>values</code></td> <td> <p>a vector containing the <i>p</i> eigenvalues of <code>x</code>, sorted in <em>decreasing</em> order, according to <code>Mod(values)</code> in the asymmetric case when they might be complex (even for real matrices). For real asymmetric matrices the vector will be complex only if complex conjugate pairs of eigenvalues are detected. </p> </td></tr> <tr valign="top"><td><code>vectors</code></td> <td> <p>either a <i>p * p</i> matrix whose columns contain the eigenvectors of <code>x</code>, or <code>NULL</code> if <code>only.values</code> is <code>TRUE</code>. The vectors are normalized to unit length. </p> <p>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). </p> </td></tr> </table> <p>When <code>only.values</code> is not true, as by default, the result is of S3 class <code>"eigen"</code>. </p> <p>If <code>r <- eigen(A)</code>, and <code>V <- r$vectors; lam <- r$values</code>, then </p> <p style="text-align: center;"><i>A = V Lmbd V^(-1)</i></p> <p> (up to numerical fuzz), where <i>Lmbd =</i><code>diag(lam)</code>. </p> <h3>Source</h3> <p><code>eigen</code> uses the LAPACK routines <code>DSYEVR</code>, <code>DGEEV</code>, <code>ZHEEV</code> and <code>ZGEEV</code>. </p> <p>LAPACK is from <a href="http://www.netlib.org/lapack">http://www.netlib.org/lapack</a> and its guide is listed in the references. </p> <h3>References</h3> <p>Anderson. E. and ten others (1999) <em>LAPACK Users' Guide</em>. Third Edition. SIAM.<br /> Available on-line at <a href="http://www.netlib.org/lapack/lug/lapack_lug.html">http://www.netlib.org/lapack/lug/lapack_lug.html</a>. </p> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <p>Wilkinson, J. H. (1965) <em>The Algebraic Eigenvalue Problem.</em> Clarendon Press, Oxford. </p> <h3>See Also</h3> <p><code><a href="svd.html">svd</a></code>, a generalization of <code>eigen</code>; <code><a href="qr.html">qr</a></code>, and <code><a href="chol.html">chol</a></code> for related decompositions. </p> <p>To compute the determinant of a matrix, the <code><a href="qr.html">qr</a></code> decomposition is much more efficient: <code><a href="det.html">det</a></code>. </p> <h3>Examples</h3> <pre> 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 Eigenvalues ## 3 x 3: eigen(cbind( 1, 3:1, 1:3)) eigen(cbind(-1, c(1:2,0), 0:2)) # complex values </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>