EVOLUTION-MANAGER
Edit File: arpack.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: ARPACK eigenvector calculation</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 arpack_defaults {igraph}"><tr><td>arpack_defaults {igraph}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>ARPACK eigenvector calculation</h2> <h3>Description</h3> <p>Interface to the ARPACK library for calculating eigenvectors of sparse matrices </p> <h3>Usage</h3> <pre> arpack_defaults arpack( func, extra = NULL, sym = FALSE, options = arpack_defaults, env = parent.frame(), complex = !sym ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>func</code></td> <td> <p>The function to perform the matrix-vector multiplication. ARPACK requires to perform these by the user. The function gets the vector <i>x</i> as the first argument, and it should return <i>Ax</i>, where <i>A</i> is the “input matrix”. (The input matrix is never given explicitly.) The second argument is <code>extra</code>.</p> </td></tr> <tr valign="top"><td><code>extra</code></td> <td> <p>Extra argument to supply to <code>func</code>.</p> </td></tr> <tr valign="top"><td><code>sym</code></td> <td> <p>Logical scalar, whether the input matrix is symmetric. Always supply <code>TRUE</code> here if it is, since it can speed up the computation.</p> </td></tr> <tr valign="top"><td><code>options</code></td> <td> <p>Options to ARPACK, a named list to overwrite some of the default option values. See details below.</p> </td></tr> <tr valign="top"><td><code>env</code></td> <td> <p>The environment in which <code>func</code> will be evaluated.</p> </td></tr> <tr valign="top"><td><code>complex</code></td> <td> <p>Whether to convert the eigenvectors returned by ARPACK into R complex vectors. By default this is not done for symmetric problems (these only have real eigenvectors/values), but only non-symmetric ones. If you have a non-symmetric problem, but you're sure that the results will be real, then supply <code>FALSE</code> here.</p> </td></tr> </table> <h3>Format</h3> <p>An object of class <code>list</code> of length 14. </p> <h3>Details</h3> <p>ARPACK is a library for solving large scale eigenvalue problems. The package is designed to compute a few eigenvalues and corresponding eigenvectors of a general <i>n</i> by <i>n</i> matrix <i>A</i>. It is most appropriate for large sparse or structured matrices <i>A</i> where structured means that a matrix-vector product <code>w <- Av</code> requires order <i>n</i> rather than the usual order <i>n^2</i> floating point operations. </p> <p>This function is an interface to ARPACK. igraph does not contain all ARPACK routines, only the ones dealing with symmetric and non-symmetric eigenvalue problems using double precision real numbers. </p> <p>The eigenvalue calculation in ARPACK (in the simplest case) involves the calculation of the <i>Av</i> product where <i>A</i> is the matrix we work with and <i>v</i> is an arbitrary vector. The function supplied in the <code>fun</code> argument is expected to perform this product. If the product can be done efficiently, e.g. if the matrix is sparse, then <code>arpack</code> is usually able to calculate the eigenvalues very quickly. </p> <p>The <code>options</code> argument specifies what kind of calculation to perform. It is a list with the following members, they correspond directly to ARPACK parameters. On input it has the following fields: </p> <dl> <dt>bmat</dt><dd><p>Character constant, possible values: ‘<code>I</code>’, standard eigenvalue problem, <i>A*x=lambda*x</i>; and ‘<code>G</code>’, generalized eigenvalue problem, <i>A*x=lambda B*x</i>. Currently only ‘<code>I</code>’ is supported.</p> </dd> <dt>n</dt><dd><p>Numeric scalar. The dimension of the eigenproblem. You only need to set this if you call <code><a href="arpack.html">arpack</a></code> directly. (I.e. not needed for <code><a href="eigen_centrality.html">eigen_centrality</a></code>, <code><a href="page_rank.html">page_rank</a></code>, etc.)</p> </dd> <dt>which</dt><dd><p>Specify which eigenvalues/vectors to compute, character constant with exactly two characters. </p> <p>Possible values for symmetric input matrices: </p> <dl> <dt>"LA"</dt><dd><p>Compute <code>nev</code> largest (algebraic) eigenvalues.</p> </dd> <dt>"SA"</dt><dd><p>Compute <code>nev</code> smallest (algebraic) eigenvalues.</p> </dd> <dt>"LM"</dt><dd><p>Compute <code>nev</code> largest (in magnitude) eigenvalues.</p> </dd> <dt>"SM"</dt><dd><p>Compute <code>nev</code> smallest (in magnitude) eigenvalues.</p> </dd> <dt>"BE"</dt><dd><p>Compute <code>nev</code> eigenvalues, half from each end of the spectrum. When <code>nev</code> is odd, compute one more from the high end than from the low end.</p> </dd> </dl> <p>Possible values for non-symmetric input matrices: </p> <dl> <dt>"LM"</dt><dd><p>Compute <code>nev</code> eigenvalues of largest magnitude.</p> </dd> <dt>"SM"</dt><dd><p>Compute <code>nev</code> eigenvalues of smallest magnitude.</p> </dd> <dt>"LR"</dt><dd><p>Compute <code>nev</code> eigenvalues of largest real part.</p> </dd> <dt>"SR"</dt><dd><p>Compute <code>nev</code> eigenvalues of smallest real part.</p> </dd> <dt>"LI"</dt><dd><p>Compute <code>nev</code> eigenvalues of largest imaginary part.</p> </dd> <dt>"SI"</dt><dd><p>Compute <code>nev</code> eigenvalues of smallest imaginary part.</p> </dd> </dl> <p>This parameter is sometimes overwritten by the various functions, e.g. <code><a href="page_rank.html">page_rank</a></code> always sets ‘<code>LM</code>’. </p> </dd> <dt>nev</dt><dd><p>Numeric scalar. The number of eigenvalues to be computed.</p> </dd> <dt>tol</dt><dd><p>Numeric scalar. Stopping criterion: the relative accuracy of the Ritz value is considered acceptable if its error is less than <code>tol</code> times its estimated value. If this is set to zero then machine precision is used.</p> </dd> <dt>ncv</dt><dd><p>Number of Lanczos vectors to be generated.</p> </dd> <dt>ldv</dt><dd><p>Numberic scalar. It should be set to zero in the current implementation.</p> </dd> <dt>ishift</dt><dd><p>Either zero or one. If zero then the shifts are provided by the user via reverse communication. If one then exact shifts with respect to the reduced tridiagonal matrix <i>T</i>. Please always set this to one.</p> </dd> <dt>maxiter</dt><dd><p>Maximum number of Arnoldi update iterations allowed. </p> </dd> <dt>nb</dt><dd><p>Blocksize to be used in the recurrence. Please always leave this on the default value, one.</p> </dd> <dt>mode</dt><dd><p>The type of the eigenproblem to be solved. Possible values if the input matrix is symmetric: </p> <dl> <dt>1</dt><dd><p><i>A*x=lambda*x</i>, <i>A</i> is symmetric.</p> </dd> <dt>2</dt><dd><p><i>A*x=lambda*M*x</i>, <i>A</i> is symmetric, <i>M</i> is symmetric positive definite.</p> </dd> <dt>3</dt><dd><p><i>K*x=lambda*M*x</i>, <i>K</i> is symmetric, <i>M</i> is symmetric positive semi-definite.</p> </dd> <dt>4</dt><dd><p><i>K*x=lambda*KG*x</i>, <i>K</i> is symmetric positive semi-definite, <i>KG</i> is symmetric indefinite.</p> </dd> <dt>5</dt><dd><p><i>A*x=lambda*M*x</i>, <i>A</i> is symmetric, <i>M</i> is symmetric positive semi-definite. (Cayley transformed mode.)</p> </dd> </dl> <p> Please note that only <code>mode==1</code> was tested and other values might not work properly. </p> <p>Possible values if the input matrix is not symmetric: </p> <dl> <dt>1</dt><dd><p><i>A*x=lambda*x</i>.</p> </dd> <dt>2</dt><dd><p><i>A*x=lambda*M*x</i>, <i>M</i> is symmetric positive definite.</p> </dd> <dt>3</dt><dd><p><i>A*x=lambda*M*x</i>, <i>M</i> is symmetric semi-definite.</p> </dd> <dt>4</dt><dd><p><i>A*x=lambda*M*x</i>, <i>M</i> is symmetric semi-definite.</p> </dd> </dl> <p> Please note that only <code>mode==1</code> was tested and other values might not work properly. </p> </dd> <dt>start</dt><dd><p>Not used currently. Later it be used to set a starting vector.</p> </dd> <dt>sigma</dt><dd><p>Not used currently.</p> </dd> <dt>sigmai</dt><dd><p>Not use currently.</p> </dd> </dl> <p>On output the following additional fields are added: </p> <dl> <dt>info</dt><dd><p>Error flag of ARPACK. Possible values: </p> <dl> <dt>0</dt><dd><p>Normal exit.</p> </dd> <dt>1</dt><dd><p>Maximum number of iterations taken.</p> </dd> <dt>3</dt><dd><p>No shifts could be applied during a cycle of the Implicitly restarted Arnoldi iteration. One possibility is to increase the size of <code>ncv</code> relative to <code>nev</code>.</p> </dd> </dl> <p>ARPACK can return more error conditions than these, but they are converted to regular igraph errors. </p> </dd> <dt>iter</dt><dd><p>Number of Arnoldi iterations taken.</p> </dd> <dt>nconv</dt><dd><p>Number of “converged” Ritz values. This represents the number of Ritz values that satisfy the convergence critetion. </p> </dd> <dt>numop</dt><dd><p>Total number of matrix-vector multiplications.</p> </dd> <dt>numopb</dt><dd><p>Not used currently.</p> </dd> <dt>numreo</dt><dd><p>Total number of steps of re-orthogonalization.</p> </dd> </dl> <p> Please see the ARPACK documentation for additional details. </p> <h3>Value</h3> <p>A named list with the following members: </p> <table summary="R valueblock"> <tr valign="top"><td><code>values</code></td> <td> <p>Numeric vector, the desired eigenvalues.</p> </td></tr> <tr valign="top"><td><code>vectors</code></td> <td> <p>Numeric matrix, the desired eigenvectors as columns. If <code>complex=TRUE</code> (the default for non-symmetric problems), then the matrix is complex.</p> </td></tr> <tr valign="top"><td><code>options</code></td> <td> <p>A named list with the supplied <code>options</code> and some information about the performed calculation, including an ARPACK exit code. See the details above. </p> </td></tr> </table> <h3>Author(s)</h3> <p>Rich Lehoucq, Kristi Maschhoff, Danny Sorensen, Chao Yang for ARPACK, Gabor Csardi <a href="mailto:csardi.gabor@gmail.com">csardi.gabor@gmail.com</a> for the R interface. </p> <h3>References</h3> <p>D.C. Sorensen, Implicit Application of Polynomial Filters in a k-Step Arnoldi Method. <em>SIAM J. Matr. Anal. Apps.</em>, 13 (1992), pp 357-385. </p> <p>R.B. Lehoucq, Analysis and Implementation of an Implicitly Restarted Arnoldi Iteration. <em>Rice University Technical Report</em> TR95-13, Department of Computational and Applied Mathematics. </p> <p>B.N. Parlett & Y. Saad, Complex Shift and Invert Strategies for Real Matrices. <em>Linear Algebra and its Applications</em>, vol 88/89, pp 575-595, (1987). </p> <h3>See Also</h3> <p><code><a href="eigen_centrality.html">eigen_centrality</a></code>, <code><a href="page_rank.html">page_rank</a></code>, <code><a href="hub_score.html">hub_score</a></code>, <code><a href="cluster_leading_eigen.html">cluster_leading_eigen</a></code> are some of the functions in igraph that use ARPACK. </p> <h3>Examples</h3> <pre> # Identity matrix f <- function(x, extra=NULL) x arpack(f, options=list(n=10, nev=2, ncv=4), sym=TRUE) # Graph laplacian of a star graph (undirected), n>=2 # Note that this is a linear operation f <- function(x, extra=NULL) { y <- x y[1] <- (length(x)-1)*x[1] - sum(x[-1]) for (i in 2:length(x)) { y[i] <- x[i] - x[1] } y } arpack(f, options=list(n=10, nev=1, ncv=3), sym=TRUE) # double check eigen(laplacian_matrix(make_star(10, mode="undirected"))) ## First three eigenvalues of the adjacency matrix of a graph ## We need the 'Matrix' package for this if (require(Matrix)) { set.seed(42) g <- sample_gnp(1000, 5/1000) M <- as_adj(g, sparse=TRUE) f2 <- function(x, extra=NULL) { cat("."); as.vector(M %*% x) } baev <- arpack(f2, sym=TRUE, options=list(n=vcount(g), nev=3, ncv=8, which="LM", maxiter=2000)) } </pre> <hr /><div style="text-align: center;">[Package <em>igraph</em> version 1.3.5 <a href="00Index.html">Index</a>]</div> </body></html>