1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_SUBSPACE_SUBSPACESOLVERLINEIG_H
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_SUBSPACE_SUBSPACESOLVERLINEIG_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>
12template <
class RT,
class QT,
class PT>
42 auto evec = std::vector<value_type>{};
46 size_t n_solutions = 0;
48 n_solutions = evec.size() / dim;
50 auto nroots = std::min(nroots_max, n_solutions);
54 m_errors.assign(
size(), std::numeric_limits<value_type_abs>::max());
71 const auto dim = h.rows();
72 const auto n_solutions = rhs.cols();
73 auto solution = std::vector<value_type>{};
79 m_errors.assign(
size(), std::numeric_limits<value_type_abs>::max());
89 void set_error(
const std::vector<int>& roots,
const std::vector<value_type_abs>&
errors)
override {
90 for (
size_t i = 0; i < roots.size(); ++i)
96 const std::vector<value_type_abs>&
errors()
const override {
return m_errors; }
SubspaceData data
Equation data in the subspace.
Definition: IXSpace.h:22
Slice slice(coord_type upper_left, coord_type bottom_right)
Access a rectangular slice of the matrix.
Definition: Matrix.h:97
void resize(const coord_type &dims)
Resize the matrix. The old data is preserved and any new rows/cols are zeroed.
Definition: Matrix.h:126
index_type rows() const
Definition: Matrix.h:165
Solves subspace problem for linear eigenvalues and system of linear equations.
Definition: SubspaceSolverLinEig.h:13
std::vector< value_type_abs > m_errors
errors in subspace solutions
Definition: SubspaceSolverLinEig.h:112
typename ISubspaceSolver< RT, QT, PT >::value_type_abs value_type_abs
Definition: SubspaceSolverLinEig.h:16
void set_error(const std::vector< int > &roots, const std::vector< value_type_abs > &errors) override
Update errors for a group of roots.
Definition: SubspaceSolverLinEig.h:89
double get_augmented_hessian()
Definition: SubspaceSolverLinEig.h:107
void set_error(int root, value_type_abs error) override
Set error value for solution root
Definition: SubspaceSolverLinEig.h:88
void solve_eigenvalue(IXSpace< R, Q, P > &xspace, const size_t nroots_max)
Definition: SubspaceSolverLinEig.h:33
value_type_abs m_svd_solver_threshold
threshold to select null space during SVD in eigenproblem
Definition: SubspaceSolverLinEig.h:116
std::vector< value_type > m_eigenvalues
eigenvalues
Definition: SubspaceSolverLinEig.h:111
bool get_hermiticity()
Definition: SubspaceSolverLinEig.h:104
Matrix< value_type > m_solutions
solution matrix with row vectors
Definition: SubspaceSolverLinEig.h:110
std::shared_ptr< Logger > m_logger
Definition: SubspaceSolverLinEig.h:113
const std::vector< value_type > & eigenvalues() const override
Access eigenvalues from the last solve() call.
Definition: SubspaceSolverLinEig.h:95
void set_augmented_hessian(double parameter)
Set value of augmented hessian parameter. If 0, than augmented Hessian is not used.
Definition: SubspaceSolverLinEig.h:106
void solve(IXSpace< R, Q, P > &xspace, const size_t nroots_max) override
Solve the subspace problem.
Definition: SubspaceSolverLinEig.h:23
void set_hermiticity(bool hermitian)
Set Hermiticity of the subspace.
Definition: SubspaceSolverLinEig.h:103
const std::vector< value_type_abs > & errors() const override
Access errors corresponding to each solution.
Definition: SubspaceSolverLinEig.h:96
double m_augmented_hessian
value of augmented hessian parameter. If 0, than augmented Hessian is not used
Definition: SubspaceSolverLinEig.h:119
SubspaceSolverLinEig(std::shared_ptr< Logger > logger)
Definition: SubspaceSolverLinEig.h:21
void solve_linear_equations(IXSpace< R, Q, P > &xspace)
Definition: SubspaceSolverLinEig.h:61
const Matrix< value_type > & solutions() const override
Access solutions from the last solve() call.
Definition: SubspaceSolverLinEig.h:94
bool m_hermitian
flags the matrix as Hermitian
Definition: SubspaceSolverLinEig.h:118
size_t size() const override
Number of solutions.
Definition: SubspaceSolverLinEig.h:99
std::string as_string(const Mat &m, int precision=6)
Definition: Matrix.h:289
void solve_LinearEquations(std::vector< value_type > &solution, std::vector< value_type > &eigenvalues, const std::vector< value_type > &matrix, const std::vector< value_type > &metric, const std::vector< value_type > &rhs, size_t dimension, size_t nroot, double augmented_hessian, double svdThreshold, int verbosity)
Definition: helper-implementation.h:546
void eigenproblem(std::vector< value_type > &eigenvectors, std::vector< value_type > &eigenvalues, const std::vector< value_type > &matrix, const std::vector< value_type > &metric, size_t dimension, bool hermitian, double svdThreshold, int verbosity, bool condone_complex)
Definition: helper-implementation.h:312
@ Info
Definition: Logger.h:49
@ Trace
Definition: Logger.h:49
@ Debug
Definition: Logger.h:49
Manages solution of the subspace problem and storage of those solutions.
Definition: ISubspaceSolver.h:15
typename array::ArrayHandler< R, R >::value_type value_type
Definition: ISubspaceSolver.h:19
typename array::ArrayHandler< R, R >::value_type_abs value_type_abs
Definition: ISubspaceSolver.h:20
PT P
Definition: ISubspaceSolver.h:18
QT Q
Definition: ISubspaceSolver.h:17
RT R
Definition: ISubspaceSolver.h:16