Linear algebra solvers

The solvers module (namespace lible::solver) provides various algorithms to solve linear algebra problems in quantum chemistry. These methods are well known and are probably ubiquitous in already existing quantum chemistry. The solvers here are implemented for the specific purpose where the involved matrices are too large to be kept in memory. Instead, a function calculating a specific matrix-vector product is required

Conjugate gradient

struct CGSettings

Structure for the convergence settings of CG and PCG solvers.

size_t max_iter_ = 100

Maximum number of iterations.

double conv_tol_ = 1e-6

Maximum absolute value of the residual to signal convergence.

struct CGResults

Structure for the results returned from CG and PCG solvers.

bool converged_

Flag for whether convergence was reached.

size_t n_iter_

Number of iterations that were run.

std::vector<double> max_abs_residuals_

Maximum absolute values of the residuals at each iteration.

std::vector<double> solution_

Obtained solution from the conjugate gradient solver.

using cg_sigma_t = std::function<std::vector<double>(const std::vector<double> &trial)>;

Type alias for the CG and PCG sigma vector function object.

using pcg_preconditioner_t = std::function<std::vector<double>(const std::vector<double> &residual)>;

Type alias for the PCG preconditioner function object.

CGResults conjugateGradient(const std::vector<double> &guess, const std::vector<double> &rhs, const cg_sigma_t &calc_sigma, const CGSettings &settings = CGSettings())

Function for running the conjugate gradient (CG) algorithm. guess is the initial guess for the solution, \(\mathbf{x}_0\); rhs is the right-hand side of the system \(\mathbf{A}\mathbf{x}=\mathbf{b}\); calc_sigma is a function object for calculating the sigma vector; settings is a CGSettings object.

CGResults preconditionedCG(const std::vector<double> &guess, const std::vector<double> &rhs, const cg_sigma_t &calc_sigma, const pcg_preconditioner_t &preconditioner, const CGSettings &settings = CGSettings())

Function for running the preconditioned conjugate gradient (CG) algorithm. guess is the initial guess for the solution, \(\mathbf{x}_0\); rhs is the right-hand side of the system, \(\mathbf{A}\mathbf{x}=\mathbf{b}\); calc_sigma is a function object for calculating the sigma vector; preconditioner is a function object for calculating the preconditioned residual; settings is a CGSettings object.