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.
-
size_t max_iter_ = 100
-
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.
-
bool converged_
-
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.
guessis the initial guess for the solution, \(\mathbf{x}_0\);rhsis the right-hand side of the system \(\mathbf{A}\mathbf{x}=\mathbf{b}\);calc_sigmais a function object for calculating the sigma vector;settingsis aCGSettingsobject.
-
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.
guessis the initial guess for the solution, \(\mathbf{x}_0\);rhsis the right-hand side of the system, \(\mathbf{A}\mathbf{x}=\mathbf{b}\);calc_sigmais a function object for calculating the sigma vector;preconditioneris a function object for calculating the preconditioned residual;settingsis aCGSettingsobject.