Spectra::LOBPCGSolver< Scalar > Class Template Reference

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

  • Knyazev, A.V., 2001. Toward the optimal preconditioned eigensolver : Locally optimal block preconditioned conjugate gradient method.SIAM journal on scientific computing, 23(2), pp.517 - 541.
  • Knyazev, A.V., Argentati, M.E., Lashuk, I. and Ovtchinnikov, E.E., 2007. Block locally optimal preconditioned eigenvalue xolvers(BLOPEX) in HYPRE and PETSc.SIAM Journal on Scientific Computing, 29(5), pp.2224 - 2239.

*** 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
Matrix 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";
Eigen::SparseMatrix<long double> A(a.sparseView());
// random X
Eigen::Matrix<long double, 10, 2> x;
x = Matrix::Random(10, 2).array();
Eigen::SparseMatrix<long double> X(x.sparseView());
// 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;

#include <LOBPCGSolver.h>

Public Member Functions

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

Public Attributes

SparseMatrix m_residuals
 
Matrix m_evectors
 
Vector m_evalues
 
int m_info
 

The documentation for this class was generated from the following file:
  • /builds/uwsbel/chrono/src/chrono_thirdparty/spectra/Spectra/contrib/LOBPCGSolver.h
*** METHOD The class represent the LOBPCG algorithm, which was invented by Andrew Knyazev Theoretical...
Definition: LOBPCGSolver.h:83