ARPACK-Eigen
|
#include <SymEigsSolver.h>
Public Member Functions | |
SymEigsSolver (OpType *op_, int nev_, int ncv_) | |
void | init (const Scalar *init_resid) |
void | init () |
int | compute (int maxit=1000, Scalar tol=1e-10) |
int | num_iterations () |
int | num_operations () |
Vector | eigenvalues () |
Matrix | eigenvectors () |
This class implements the eigen solver for real symmetric matrices.
ARPACK-Eigen is designed to calculate a specified number ( \(k\)) of eigenvalues of a large square matrix ( \(A\)). Usually \(k\) is much less than the size of the matrix ( \(n\)), so that only a few eigenvalues and eigenvectors are computed.
This class implements the eigen solver of a real symmetric matrix, but rather than providing the whole matrix, the algorithm only requires the matrix-vector multiplication operation of \(A\). Therefore, users of this solver need to supply a class that computes the result of \(Av\) for any given vector \(v\). The name of this class should be given to the template parameter OpType
, and instance of this class passed to the constructor of SymEigsSolver.
If the matrix \(A\) is already stored as a matrix object in Eigen, for example Eigen::MatrixXd
, then there is an easy way to construct such matrix operation class, by using the built-in wrapper class DenseGenMatProd which wraps an existing matrix object in Eigen. This is also the default template parameter for SymEigsSolver.
If the users need to define their own matrix-vector multiplication operation class, it should impelement all the public member functions as in DenseGenMatProd.
Scalar | The element type of the matrix. Currently supported types are float , double and long double . |
SelectionRule | An enumeration value indicating the selection rule of the requested eigenvalues, for example LARGEST_MAGN to retrieve eigenvalues with the largest magnitude. The full list of enumeration values can be found in SelectionRule.h . |
OpType | The name of the matrix operation class. Users could either use the DenseGenMatProd wrapper class, or define their own that impelemnts all the public member functions as in DenseGenMatProd. |
Below is an example that demonstrates the usage of this class.
And here is an example for user-supplied matrix operation class.
Definition at line 138 of file SymEigsSolver.h.
|
inline |
Constructor to create a solver object.
op_ | Pointer to the matrix operation object, which should implement the matrix-vector multiplication operation of \(A\): calculating \(Ay\) for any vector \(y\). Users could either create the object from the DenseGenMatProd wrapper class, or define their own that impelemnts all the public member functions as in DenseGenMatProd. |
nev_ | Number of eigenvalues requested. This should satisfy \(1\le nev \le n-1\), where \(n\) is the size of matrix. |
ncv_ | Parameter that controls the convergence speed of the algorithm. Typically a larger ncv_ means faster convergence, but it may also result in greater memory use and more matrix operations in each iteration. This parameter must satisfy \(nev < ncv \le n\), and is advised to take \(ncv \ge 2\cdot nev\). |
Definition at line 377 of file SymEigsSolver.h.
|
inline |
Providing the initial residual vector for the algorithm.
init_resid | Pointer to the initial residual vector. |
ARPACK-Eigen (and also ARPACK) uses an iterative algorithm to find eigenvalues. This function allows the user to provide the initial residual vector.
Definition at line 402 of file SymEigsSolver.h.
|
inline |
Providing a random initial residual vector.
This overloaded function generates a random initial residual vector for the algorithm. Elements in the vector follow independent Uniform(-0.5, 0.5) distributions.
Definition at line 445 of file SymEigsSolver.h.
|
inline |
Conducting the major computation procedure.
maxit | Maximum number of iterations allowed in the algorithm. |
tol | Precision parameter for the calculated eigenvalues. |
Definition at line 460 of file SymEigsSolver.h.
|
inline |
Returning the number of iterations used in the computation.
Definition at line 487 of file SymEigsSolver.h.
|
inline |
Returning the number of matrix operations used in the computation.
Definition at line 492 of file SymEigsSolver.h.
|
inline |
Returning the converged eigenvalues.
Eigen::Vector<Scalar, ...>
, depending on the template parameter Scalar
defined. Definition at line 501 of file SymEigsSolver.h.
|
inline |
Returning the eigenvectors associated with the converged eigenvalues.
Eigen::Matrix<Scalar, ...>
, depending on the template parameter Scalar
defined. Definition at line 529 of file SymEigsSolver.h.