1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/eigen.R 3\name{partial_eigen} 4\alias{partial_eigen} 5\title{Find a few approximate largest eigenvalues and corresponding eigenvectors of a symmetric matrix.} 6\usage{ 7partial_eigen(x, n = 5, symmetric = TRUE, ...) 8} 9\arguments{ 10\item{x}{numeric real-valued dense or sparse matrix.} 11 12\item{n}{number of largest eigenvalues and corresponding eigenvectors to compute.} 13 14\item{symmetric}{\code{TRUE} indicates \code{x} is a symmetric matrix (the default); 15specify \code{symmetric=FALSE} to compute the largest eigenvalues and corresponding 16eigenvectors of \code{t(x) \%*\% x} instead.} 17 18\item{...}{optional additional parameters passed to the \code{irlba} function.} 19} 20\value{ 21Returns a list with entries: 22\itemize{ 23 \item{values}{ n approximate largest eigenvalues} 24 \item{vectors}{ n approximate corresponding eigenvectors} 25} 26} 27\description{ 28Use \code{partial_eigen} to estimate a subset of the largest (most positive) 29eigenvalues and corresponding eigenvectors of a symmetric dense or sparse 30real-valued matrix. 31} 32\note{ 33Specify \code{symmetric=FALSE} to compute the largest \code{n} eigenvalues 34and corresponding eigenvectors of the symmetric matrix cross-product 35\code{t(x) \%*\% x}. 36 37This function uses the \code{irlba} function under the hood. See \code{?irlba} 38for description of additional options, especially the \code{tol} parameter. 39 40See the RSpectra package https://cran.r-project.org/package=RSpectra for more comprehensive 41partial eigenvalue decomposition. 42} 43\examples{ 44set.seed(1) 45# Construct a symmetric matrix with some positive and negative eigenvalues: 46V <- qr.Q(qr(matrix(runif(100), nrow=10))) 47x <- V \%*\% diag(c(10, -9, 8, -7, 6, -5, 4, -3, 2, -1)) \%*\% t(V) 48partial_eigen(x, 3)$values 49 50# Compare with eigen 51eigen(x)$values[1:3] 52 53# Use symmetric=FALSE to compute the eigenvalues of t(x) \%*\% x for general 54# matrices x: 55x <- matrix(rnorm(100), 10) 56partial_eigen(x, 3, symmetric=FALSE)$values 57eigen(crossprod(x))$values 58 59} 60\references{ 61Augmented Implicitly Restarted Lanczos Bidiagonalization Methods, J. Baglama and L. Reichel, SIAM J. Sci. Comput. 2005. 62} 63\seealso{ 64\code{\link{eigen}}, \code{\link{irlba}} 65} 66 67