Public Member Functions | Private Types | Private Attributes | List of all members
Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY > Class Template Reference

#include <SymGEigsSolver.h>

Inheritance diagram for Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY >:
Inheritance graph
[legend]

Public Member Functions

 SymGEigsSolver (OpType *op, BOpType *Bop, Index nev, Index ncv)
 
- Public Member Functions inherited from Spectra::SymEigsBase< Scalar, SelectionRule, SymGEigsCholeskyOp< Scalar, OpType, BOpType >, IdentityBOp >
Index compute (Index maxit=1000, Scalar tol=1e-10, int sort_rule=LARGEST_ALGE)
 
Vector eigenvalues () const
 
virtual Matrix eigenvectors (Index nvec) const
 
virtual Matrix eigenvectors () const
 
int info () const
 
void init (const Scalar *init_resid)
 
void init ()
 
Index num_iterations () const
 
Index num_operations () const
 

Private Types

typedef Eigen::Index Index
 
typedef Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::DynamicMatrix
 
typedef Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
 

Private Attributes

BOpType * m_Bop
 

Additional Inherited Members

- Protected Member Functions inherited from Spectra::SymEigsBase< Scalar, SelectionRule, SymGEigsCholeskyOp< Scalar, OpType, BOpType >, IdentityBOp >
virtual void sort_ritzpair (int sort_rule)
 
- Protected Attributes inherited from Spectra::SymEigsBase< Scalar, SelectionRule, SymGEigsCholeskyOp< Scalar, OpType, BOpType >, IdentityBOp >
LanczosFac m_fac
 
const Index m_n
 
const Index m_ncv
 
const Index m_nev
 
Index m_niter
 
Index m_nmatop
 
SymGEigsCholeskyOp< Scalar, OpType, BOpType > * m_op
 
Vector m_ritz_val
 

Detailed Description

template<typename Scalar, int SelectionRule, typename OpType, typename BOpType>
class Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY >

This class implements the generalized eigen solver for real symmetric matrices using Cholesky decomposition, i.e., to solve $Ax=\lambda Bx$ where $A$ is symmetric and $B$ is positive definite with the Cholesky decomposition $B=LL'$.

This solver requires two matrix operation objects: one for $A$ that implements the matrix multiplication $Av$, and one for $B$ that implements the lower and upper triangular solving $L^{-1}v$ and $(L')^{-1}v$.

If $A$ and $B$ are stored as Eigen matrices, then the first operation can be created using the DenseSymMatProd or SparseSymMatProd classes, and the second operation can be created using the DenseCholesky or SparseCholesky classes. If the users need to define their own operation classes, then they should implement all the public member functions as in those built-in classes.

Template Parameters
ScalarThe element type of the matrix. Currently supported types are float, double and long double.
SelectionRuleAn 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 Enumerations.
OpTypeThe name of the matrix operation class for $A$. Users could either use the wrapper classes such as DenseSymMatProd and SparseSymMatProd, or define their own that implements all the public member functions as in DenseSymMatProd.
BOpTypeThe name of the matrix operation class for $B$. Users could either use the wrapper classes such as DenseCholesky and SparseCholesky, or define their own that implements all the public member functions as in DenseCholesky.
GEigsModeMode of the generalized eigen solver. In this solver it is Spectra::GEIGS_CHOLESKY.

Below is an example that demonstrates the usage of this class.

#include <Eigen/Core>
#include <Eigen/SparseCore>
#include <Eigen/Eigenvalues>
#include <iostream>
using namespace Spectra;
int main()
{
// We are going to solve the generalized eigenvalue problem A * x = lambda * B * x
const int n = 100;
// Define the A matrix
Eigen::MatrixXd M = Eigen::MatrixXd::Random(n, n);
Eigen::MatrixXd A = M + M.transpose();
// Define the B matrix, a band matrix with 2 on the diagonal and 1 on the subdiagonals
B.reserve(Eigen::VectorXi::Constant(n, 3));
for(int i = 0; i < n; i++)
{
B.insert(i, i) = 2.0;
if(i > 0)
B.insert(i - 1, i) = 1.0;
if(i < n - 1)
B.insert(i + 1, i) = 1.0;
}
// Construct matrix operation object using the wrapper classes
// Construct generalized eigen solver object, requesting the largest three generalized eigenvalues
geigs(&op, &Bop, 3, 6);
// Initialize and compute
geigs.init();
int nconv = geigs.compute();
// Retrieve results
Eigen::VectorXd evalues;
Eigen::MatrixXd evecs;
if(geigs.info() == SUCCESSFUL)
{
evalues = geigs.eigenvalues();
evecs = geigs.eigenvectors();
}
std::cout << "Generalized eigenvalues found:\n" << evalues << std::endl;
std::cout << "Generalized eigenvectors found:\n" << evecs.topRows(10) << std::endl;
// Verify results using the generalized eigen solver in Eigen
Eigen::MatrixXd Bdense = B;
std::cout << "Generalized eigenvalues:\n" << es.eigenvalues().tail(3) << std::endl;
std::cout << "Generalized eigenvectors:\n" << es.eigenvectors().rightCols(3).topRows(10) << std::endl;
return 0;
}

Definition at line 164 of file SymGEigsSolver.h.

Member Typedef Documentation

template<typename Scalar , int SelectionRule, typename OpType , typename BOpType >
typedef Eigen::Index Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY >::Index
private

Definition at line 168 of file SymGEigsSolver.h.

template<typename Scalar , int SelectionRule, typename OpType , typename BOpType >
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY >::Matrix
private

Definition at line 169 of file SymGEigsSolver.h.

template<typename Scalar , int SelectionRule, typename OpType , typename BOpType >
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY >::Vector
private

Definition at line 170 of file SymGEigsSolver.h.

Constructor & Destructor Documentation

template<typename Scalar , int SelectionRule, typename OpType , typename BOpType >
Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY >::SymGEigsSolver ( OpType *  op,
BOpType *  Bop,
Index  nev,
Index  ncv 
)
inline

Constructor to create a solver object.

Parameters
opPointer to the $A$ matrix operation object. It should implement the matrix-vector multiplication operation of $A$: calculating $Av$ for any vector $v$. Users could either create the object from the wrapper classes such as DenseSymMatProd, or define their own that implements all the public member functions as in DenseSymMatProd.
BopPointer to the $B$ matrix operation object. It represents a Cholesky decomposition of $B$, and should implement the lower and upper triangular solving operations: calculating $L^{-1}v$ and $(L')^{-1}v$ for any vector $v$, where $LL'=B$. Users could either create the object from the wrapper classes such as DenseCholesky, or define their own that implements all the public member functions as in DenseCholesky.
nevNumber of eigenvalues requested. This should satisfy $1\le nev \le n-1$, where $n$ is the size of matrix.
ncvParameter 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 200 of file SymGEigsSolver.h.

Member Data Documentation

template<typename Scalar , int SelectionRule, typename OpType , typename BOpType >
BOpType* Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY >::m_Bop
private

Definition at line 172 of file SymGEigsSolver.h.


The documentation for this class was generated from the following file:


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:59:21