1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_SUBSPACE_SUBSPACESOLVERDIIS_H
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_SUBSPACE_SUBSPACESOLVERDIIS_H
3#include <molpro/linalg/itsolv/subspace/ISubspaceSolver.h>
4#include <molpro/linalg/itsolv/subspace/IXSpace.h>
5#include <molpro/linalg/itsolv/subspace/Matrix.h>
6#include <molpro/linalg/itsolv/Logger.h>
15template <
class RT,
class QT,
class PT>
17 const bool& m_converged;
27 : m_converged(converged),
m_logger(std::move(logger)) {}
30 m_logger->trace(
"SubspaceSolverDIIS::solve");
36 auto kDim = kH.rows();
55 std::vector<value_type> solution(kDim);
56 std::vector<value_type> matrix;
57 matrix.reserve(kDim * kDim);
59 for (
size_t i = 0; i < kDim; ++i)
60 for (
size_t j = 0; j < kDim; ++j)
61 matrix.push_back(kH(j, i));
64 for (
size_t i = 0; i < kDim; ++i)
73 void set_error(
const std::vector<int>& roots,
const std::vector<value_type_abs>&
errors)
override {
74 for (
size_t i = 0; i < roots.size(); ++i)
80 throw std::logic_error(
"eigenvalues() not available in non-linear method");
82 const std::vector<value_type_abs>&
errors()
const override {
return m_errors; }
SubspaceData data
Equation data in the subspace.
Definition: IXSpace.h:28
void fill(T value)
Sets all elements of matrix to value.
Definition: Matrix.h:91
void resize(const coord_type &dims)
Resize the matrix. The old data is preserved and any new rows/cols are zeroed.
Definition: Matrix.h:128
index_type rows() const
Definition: Matrix.h:167
Solves non-linear equations using DIIS.
Definition: SubspaceSolverDIIS.h:16
const std::vector< value_type > & eigenvalues() const override
Access eigenvalues from the last solve() call.
Definition: SubspaceSolverDIIS.h:79
std::shared_ptr< Logger > m_logger
Definition: SubspaceSolverDIIS.h:92
const Matrix< value_type > & solutions() const override
Access solutions from the last solve() call.
Definition: SubspaceSolverDIIS.h:78
const std::vector< value_type_abs > & errors() const override
Access errors corresponding to each solution.
Definition: SubspaceSolverDIIS.h:82
typename ISubspaceSolver< RT, QT, PT >::value_type value_type
Definition: SubspaceSolverDIIS.h:20
void set_logger(std::shared_ptr< Logger > logger) override
Definition: SubspaceSolverDIIS.h:87
std::vector< value_type_abs > m_errors
errors in subspace solutions
Definition: SubspaceSolverDIIS.h:91
void set_error(int root, value_type_abs error) override
Set error value for solution root
Definition: SubspaceSolverDIIS.h:72
void set_error(const std::vector< int > &roots, const std::vector< value_type_abs > &errors) override
Update errors for a group of roots.
Definition: SubspaceSolverDIIS.h:73
Matrix< value_type > m_solutions
solution matrix with row vectors
Definition: SubspaceSolverDIIS.h:90
typename ISubspaceSolver< RT, QT, PT >::value_type_abs value_type_abs
Definition: SubspaceSolverDIIS.h:21
SubspaceSolverDIIS(std::shared_ptr< Logger > logger, const bool &converged)
Definition: SubspaceSolverDIIS.h:26
void solve(IXSpace< R, Q, P > &xspace, const size_t nroots_max) override
Solve the subspace problem.
Definition: SubspaceSolverDIIS.h:29
value_type_abs m_svd_solver_threshold
threshold to select null space during SVD in eigenproblem
Definition: SubspaceSolverDIIS.h:95
size_t size() const override
Number of solutions.
Definition: SubspaceSolverDIIS.h:85
void solve_DIIS(std::vector< value_type > &solution, const std::vector< value_type > &matrix, size_t dimension, double svdThreshold, int verbosity=0)
Definition: helper-implementation.h:560
Manages solution of the subspace problem and storage of those solutions.
Definition: ISubspaceSolver.h:21
typename array::ArrayHandler< R, R >::value_type value_type
Definition: ISubspaceSolver.h:25
typename array::ArrayHandler< R, R >::value_type_abs value_type_abs
Definition: ISubspaceSolver.h:26
PT P
Definition: ISubspaceSolver.h:24
QT Q
Definition: ISubspaceSolver.h:23
RT R
Definition: ISubspaceSolver.h:22