Description
template<typename OpType = DenseSymMatProd<double>>
class Spectra::SymEigsSolver< OpType >
This class implements the eigen solver for real symmetric matrices, i.e., to solve \(Ax=\lambda x\) where \(A\) is symmetric.
Spectra 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.
Rather than providing the whole \(A\) 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 a matrix operation class, by using the built-in wrapper class DenseSymMatProd that wraps an existing matrix object in Eigen. This is also the default template parameter for SymEigsSolver. For sparse matrices, the wrapper class SparseSymMatProd can be used similarly.
If the users need to define their own matrix-vector multiplication operation class, it should define a public type Scalar to indicate the element type, and implement all the public member functions as in DenseSymMatProd.
- Template Parameters
-
OpType The name of the matrix operation class. Users could either use the wrapper classes such as DenseSymMatProd and SparseSymMatProd, or define their own that implements the type definition Scalarand all the public member functions as in DenseSymMatProd.
Below is an example that demonstrates the usage of this class.
And here is an example for user-supplied matrix operation class.
#include <SymEigsSolver.h>


Public Member Functions | |
| SymEigsSolver (OpType &op, Index nev, Index ncv) | |
| Constructor to create a solver object. More... | |
Public Member Functions inherited from Spectra::HermEigsBase< DenseSymMatProd< double >, IdentityBOp > | |
| void | init (const Scalar *init_resid) |
| Initializes the solver by providing an initial residual vector. More... | |
| void | init () |
| Initializes the solver by providing a random initial residual vector. More... | |
| Index | compute (SortRule selection=SortRule::LargestMagn, Index maxit=1000, RealScalar tol=1e-10, SortRule sorting=SortRule::LargestAlge) |
| Conducts the major computation procedure. More... | |
| CompInfo | info () const |
| Returns the status of the computation. More... | |
| Index | num_iterations () const |
| Returns the number of iterations used in the computation. | |
| Index | num_operations () const |
| Returns the number of matrix operations used in the computation. | |
| RealVector | eigenvalues () const |
| Returns the converged eigenvalues. More... | |
| virtual Matrix | eigenvectors (Index nvec) const |
| Returns the eigenvectors associated with the converged eigenvalues. More... | |
| virtual Matrix | eigenvectors () const |
| Returns all converged eigenvectors. | |
Additional Inherited Members | |
Protected Member Functions inherited from Spectra::HermEigsBase< DenseSymMatProd< double >, IdentityBOp > | |
| virtual void | sort_ritzpair (SortRule sort_rule) |
Protected Attributes inherited from Spectra::HermEigsBase< DenseSymMatProd< double >, IdentityBOp > | |
| std::vector< DenseSymMatProd< double > > | m_op_container |
| const DenseSymMatProd< double > & | m_op |
| const Index | m_n |
| const Index | m_nev |
| const Index | m_ncv |
| Index | m_nmatop |
| Index | m_niter |
| LanczosFac | m_fac |
| RealVector | m_ritz_val |
Constructor & Destructor Documentation
◆ SymEigsSolver()
|
inline |
Constructor to create a solver object.
- Parameters
-
op The matrix operation object that implements the matrix-vector multiplication operation of \(A\): calculating \(Av\) for any vector \(v\). Users could either create the object from the wrapper class such as DenseSymMatProd, or define their own that implements all the public members as in DenseSymMatProd. 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 ncvmeans 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\).
The documentation for this class was generated from the following file:
- /builds/uwsbel/chrono/src/chrono_thirdparty/spectra/Spectra/SymEigsSolver.h
Public Member Functions inherited from