Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
Spectra::LOBPCGSolver< Scalar > Class Template Reference

#include <LOBPCGSolver.h>

Public Member Functions

void compute (int maxit=10, Scalar tol_div_n=1e-7)
 
Vector eigenvalues ()
 
Matrix eigenvectors ()
 
int info ()
 
 LOBPCGSolver (const SparseMatrix &A, const SparseMatrix X)
 
Matrix residuals ()
 
void setB (const SparseMatrix &B)
 
void setConstraints (const SparseMatrix &Y)
 
void setPreconditioner (const SparseMatrix &preconditioner)
 

Public Attributes

Vector m_evalues
 
Matrix m_evectors
 
int m_info
 
SparseMatrix m_residuals
 

Private Types

typedef std::complex< ScalarComplex
 
typedef Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::DynamicComplexMatrix
 
typedef Eigen::Matrix< Complex, Eigen::Dynamic, 1 > ComplexVector
 
typedef Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::DynamicMatrix
 
typedef Eigen::SparseMatrix< ComplexSparseComplexMatrix
 
typedef Eigen::SparseMatrix< ScalarSparseMatrix
 
typedef Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
 

Private Member Functions

void applyConstraintsInPlace (SparseMatrix &X, SparseMatrix &Y, SparseMatrix &B)
 
int checkConvergence_getBlocksize (SparseMatrix &m_residuals, Scalar tolerance_L2, std::vector< int > &columnsToDelete)
 
int orthogonalizeInPlace (SparseMatrix &M, SparseMatrix &B, SparseMatrix &true_BM, bool has_true_BM=false)
 
void removeColumns (SparseMatrix &matrix, std::vector< int > &colToRemove)
 
void sort_epairs (Vector &evalues, Matrix &evectors, int SelectionRule)
 
Matrix stack_4_matricies (Matrix A, Matrix B, Matrix C, Matrix D)
 
Matrix stack_9_matricies (Matrix A, Matrix B, Matrix C, Matrix D, Matrix E, Matrix F, Matrix G, Matrix H, Matrix I)
 

Private Attributes

SparseMatrix A
 
bool flag_with_B
 
bool flag_with_constraints
 
bool flag_with_preconditioner
 
SparseMatrix m_B
 
const int m_n
 
const int m_nev
 
SparseMatrix m_preconditioner
 
SparseMatrix m_Y
 
SparseMatrix X
 

Detailed Description

template<typename Scalar = long double>
class Spectra::LOBPCGSolver< Scalar >

*** METHOD The class represent the LOBPCG algorithm, which was invented by Andrew Knyazev Theoretical background of the procedure can be found in the articles below

*** CONDITIONS OF USE Locally Optimal Block Preconditioned Conjugate Gradient(LOBPCG) is a method for finding the M smallest eigenvalues and eigenvectors of a large symmetric positive definite generalized eigenvalue problem $Ax=\lambda Bx,$ where $A_{NxN}$ is a symmetric matrix, $B$ is symmetric and positive - definite. $A and B$ are also assumed large and sparse $\textit{M}$ should be $\<< textit{N}$ (at least $\textit{5M} < \textit{N} $)

*** ARGUMENTS Eigen::SparseMatrix<long double> A; // N*N - Ax = lambda*Bx, lrage and sparse Eigen::SparseMatrix<long double> X; // N*M - initial approximations to eigenvectors (random in general case) Spectra::LOBPCGSolver<long double> solver(A, X); *Eigen::SparseMatrix<long double> B; // N*N - Ax = lambda*Bx, sparse, positive definite solver.setConstraints(B); *Eigen::SparseMatrix<long double> Y; // N*K - constraints, already found eigenvectors solver.setB(B); *Eigen::SparseMatrix<long double> T; // N*N - preconditioner ~ A^-1 solver.setPreconditioner(T);

*** OUTCOMES solver.solve(); // compute eigenpairs // void solver.info(); // state of converjance // int solver.residuals(); // get residuals to evaluate biases // Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> solver.eigenvalues(); // get eigenvalues // Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> solver.eigenvectors(); // get eigenvectors // Eigen::Matrix<Scalar, Eigen::Dynamic, 1>

*** EXAMPLE

#include <Spectra/contrib/SymSparseEigsSolverLOBPCG.h>
// random A
a = (Matrix::Random(10, 10).array() > 0.6).cast<long double>() * Matrix::Random(10, 10).array() * 5;
a = Matrix((a).triangularView<Eigen::Lower>()) + Matrix((a).triangularView<Eigen::Lower>()).transpose();
for (int i = 0; i < 10; i++)
a(i, i) = i + 0.5;
std::cout << a << "\n";
// random X
x = Matrix::Random(10, 2).array();
// solve Ax = lambda*x
solver.compute(10, 1e-4); // 10 iterations, L2_tolerance = 1e-4*N
std::cout << "info\n" << solver.info() << std::endl;
std::cout << "eigenvalues\n" << solver.eigenvalues() << std::endl;
std::cout << "eigenvectors\n" << solver.eigenvectors() << std::endl;
std::cout << "residuals\n" << solver.residuals() << std::endl;

Definition at line 83 of file LOBPCGSolver.h.

Member Typedef Documentation

template<typename Scalar = long double>
typedef std::complex<Scalar> Spectra::LOBPCGSolver< Scalar >::Complex
private

Definition at line 89 of file LOBPCGSolver.h.

template<typename Scalar = long double>
typedef Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic> Spectra::LOBPCGSolver< Scalar >::ComplexMatrix
private

Definition at line 90 of file LOBPCGSolver.h.

template<typename Scalar = long double>
typedef Eigen::Matrix<Complex, Eigen::Dynamic, 1> Spectra::LOBPCGSolver< Scalar >::ComplexVector
private

Definition at line 91 of file LOBPCGSolver.h.

template<typename Scalar = long double>
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Spectra::LOBPCGSolver< Scalar >::Matrix
private

Definition at line 86 of file LOBPCGSolver.h.

template<typename Scalar = long double>
typedef Eigen::SparseMatrix<Complex> Spectra::LOBPCGSolver< Scalar >::SparseComplexMatrix
private

Definition at line 94 of file LOBPCGSolver.h.

template<typename Scalar = long double>
typedef Eigen::SparseMatrix<Scalar> Spectra::LOBPCGSolver< Scalar >::SparseMatrix
private

Definition at line 93 of file LOBPCGSolver.h.

template<typename Scalar = long double>
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Spectra::LOBPCGSolver< Scalar >::Vector
private

Definition at line 87 of file LOBPCGSolver.h.

Constructor & Destructor Documentation

template<typename Scalar = long double>
Spectra::LOBPCGSolver< Scalar >::LOBPCGSolver ( const SparseMatrix A,
const SparseMatrix  X 
)
inline

Definition at line 291 of file LOBPCGSolver.h.

Member Function Documentation

template<typename Scalar = long double>
void Spectra::LOBPCGSolver< Scalar >::applyConstraintsInPlace ( SparseMatrix X,
SparseMatrix Y,
SparseMatrix B 
)
inlineprivate

Definition at line 170 of file LOBPCGSolver.h.

template<typename Scalar = long double>
int Spectra::LOBPCGSolver< Scalar >::checkConvergence_getBlocksize ( SparseMatrix m_residuals,
Scalar  tolerance_L2,
std::vector< int > &  columnsToDelete 
)
inlineprivate

Definition at line 266 of file LOBPCGSolver.h.

template<typename Scalar = long double>
void Spectra::LOBPCGSolver< Scalar >::compute ( int  maxit = 10,
Scalar  tol_div_n = 1e-7 
)
inline

Definition at line 328 of file LOBPCGSolver.h.

template<typename Scalar = long double>
Vector Spectra::LOBPCGSolver< Scalar >::eigenvalues ( )
inline

Definition at line 532 of file LOBPCGSolver.h.

template<typename Scalar = long double>
Matrix Spectra::LOBPCGSolver< Scalar >::eigenvectors ( )
inline

Definition at line 537 of file LOBPCGSolver.h.

template<typename Scalar = long double>
int Spectra::LOBPCGSolver< Scalar >::info ( )
inline

Definition at line 547 of file LOBPCGSolver.h.

template<typename Scalar = long double>
int Spectra::LOBPCGSolver< Scalar >::orthogonalizeInPlace ( SparseMatrix M,
SparseMatrix B,
SparseMatrix true_BM,
bool  has_true_BM = false 
)
inlineprivate

Definition at line 110 of file LOBPCGSolver.h.

template<typename Scalar = long double>
void Spectra::LOBPCGSolver< Scalar >::removeColumns ( SparseMatrix matrix,
std::vector< int > &  colToRemove 
)
inlineprivate

Definition at line 245 of file LOBPCGSolver.h.

template<typename Scalar = long double>
Matrix Spectra::LOBPCGSolver< Scalar >::residuals ( )
inline

Definition at line 542 of file LOBPCGSolver.h.

template<typename Scalar = long double>
void Spectra::LOBPCGSolver< Scalar >::setB ( const SparseMatrix B)
inline

Definition at line 314 of file LOBPCGSolver.h.

template<typename Scalar = long double>
void Spectra::LOBPCGSolver< Scalar >::setConstraints ( const SparseMatrix Y)
inline

Definition at line 308 of file LOBPCGSolver.h.

template<typename Scalar = long double>
void Spectra::LOBPCGSolver< Scalar >::setPreconditioner ( const SparseMatrix preconditioner)
inline

Definition at line 322 of file LOBPCGSolver.h.

template<typename Scalar = long double>
void Spectra::LOBPCGSolver< Scalar >::sort_epairs ( Vector evalues,
Matrix evectors,
int  SelectionRule 
)
inlineprivate

Definition at line 224 of file LOBPCGSolver.h.

template<typename Scalar = long double>
Matrix Spectra::LOBPCGSolver< Scalar >::stack_4_matricies ( Matrix  A,
Matrix  B,
Matrix  C,
Matrix  D 
)
inlineprivate

Definition at line 195 of file LOBPCGSolver.h.

template<typename Scalar = long double>
Matrix Spectra::LOBPCGSolver< Scalar >::stack_9_matricies ( Matrix  A,
Matrix  B,
Matrix  C,
Matrix  D,
Matrix  E,
Matrix  F,
Matrix  G,
Matrix  H,
Matrix  I 
)
inlineprivate

Definition at line 206 of file LOBPCGSolver.h.

Member Data Documentation

template<typename Scalar = long double>
SparseMatrix Spectra::LOBPCGSolver< Scalar >::A
private

Definition at line 98 of file LOBPCGSolver.h.

template<typename Scalar = long double>
bool Spectra::LOBPCGSolver< Scalar >::flag_with_B
private

Definition at line 100 of file LOBPCGSolver.h.

template<typename Scalar = long double>
bool Spectra::LOBPCGSolver< Scalar >::flag_with_constraints
private

Definition at line 100 of file LOBPCGSolver.h.

template<typename Scalar = long double>
bool Spectra::LOBPCGSolver< Scalar >::flag_with_preconditioner
private

Definition at line 100 of file LOBPCGSolver.h.

template<typename Scalar = long double>
SparseMatrix Spectra::LOBPCGSolver< Scalar >::m_B
private

Definition at line 99 of file LOBPCGSolver.h.

template<typename Scalar = long double>
Vector Spectra::LOBPCGSolver< Scalar >::m_evalues

Definition at line 105 of file LOBPCGSolver.h.

template<typename Scalar = long double>
Matrix Spectra::LOBPCGSolver< Scalar >::m_evectors

Definition at line 104 of file LOBPCGSolver.h.

template<typename Scalar = long double>
int Spectra::LOBPCGSolver< Scalar >::m_info

Definition at line 106 of file LOBPCGSolver.h.

template<typename Scalar = long double>
const int Spectra::LOBPCGSolver< Scalar >::m_n
private

Definition at line 96 of file LOBPCGSolver.h.

template<typename Scalar = long double>
const int Spectra::LOBPCGSolver< Scalar >::m_nev
private

Definition at line 97 of file LOBPCGSolver.h.

template<typename Scalar = long double>
SparseMatrix Spectra::LOBPCGSolver< Scalar >::m_preconditioner
private

Definition at line 99 of file LOBPCGSolver.h.

template<typename Scalar = long double>
SparseMatrix Spectra::LOBPCGSolver< Scalar >::m_residuals

Definition at line 103 of file LOBPCGSolver.h.

template<typename Scalar = long double>
SparseMatrix Spectra::LOBPCGSolver< Scalar >::m_Y
private

Definition at line 99 of file LOBPCGSolver.h.

template<typename Scalar = long double>
SparseMatrix Spectra::LOBPCGSolver< Scalar >::X
private

Definition at line 98 of file LOBPCGSolver.h.


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


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