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>
6#include <molpro/linalg/itsolv/Logger.h>
7#include <molpro/linalg/itsolv/helper.h>
16template <
class RT,
class QT,
class PT>
28 m_logger->trace(
"SubspaceSolverLinEig::solve");
53 m_logger->trace(
"SubspaceSolverLinEig::solve_eigenvalue");
59 auto evec = std::vector<value_type>{};
63 size_t n_solutions = 0;
65 n_solutions = evec.size() / dim;
67 auto nroots = std::min(nroots_max, n_solutions);
71 m_errors.assign(
size(), std::numeric_limits<value_type_abs>::max());
77 m_logger->trace(
"SubspaceSolverLinEig::solve_linear_equations");
83 m_logger->data_dump<15>(
"rhs = ", rhs);
84 const auto dim = h.rows();
85 const auto n_solutions = rhs.cols();
86 auto solution = std::vector<value_type>{};
92 m_errors.assign(
size(), std::numeric_limits<value_type_abs>::max());
100 void set_error(
const std::vector<int>& roots,
const std::vector<value_type_abs>&
errors)
override {
101 for (
size_t i = 0; i < roots.size(); ++i)
SubspaceData data
Equation data in the subspace.
Definition: IXSpace.h:28
Slice slice(coord_type upper_left, coord_type bottom_right)
Access a rectangular slice of the matrix.
Definition: Matrix.h:99
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 subspace problem for linear eigenvalues and system of linear equations.
Definition: SubspaceSolverLinEig.h:17
std::vector< value_type_abs > m_errors
errors in subspace solutions
Definition: SubspaceSolverLinEig.h:125
typename ISubspaceSolver< RT, QT, PT >::value_type_abs value_type_abs
Definition: SubspaceSolverLinEig.h:20
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:100
double get_augmented_hessian()
Definition: SubspaceSolverLinEig.h:120
void set_logger(std::shared_ptr< Logger > logger) override
Definition: SubspaceSolverLinEig.h:112
void set_error(int root, value_type_abs error) override
Set error value for solution root
Definition: SubspaceSolverLinEig.h:99
void solve_eigenvalue(IXSpace< R, Q, P > &xspace, const size_t nroots_max)
Definition: SubspaceSolverLinEig.h:52
value_type_abs m_svd_solver_threshold
threshold to select null space during SVD in eigenproblem
Definition: SubspaceSolverLinEig.h:129
std::vector< value_type > m_eigenvalues
eigenvalues
Definition: SubspaceSolverLinEig.h:124
bool get_hermiticity()
Definition: SubspaceSolverLinEig.h:117
Matrix< value_type > m_solutions
solution matrix with row vectors
Definition: SubspaceSolverLinEig.h:123
std::shared_ptr< Logger > m_logger
Definition: SubspaceSolverLinEig.h:126
const std::vector< value_type > & eigenvalues() const override
Access eigenvalues from the last solve() call.
Definition: SubspaceSolverLinEig.h:106
typename ISubspaceSolver< RT, QT, PT >::value_type value_type
Definition: SubspaceSolverLinEig.h:19
void set_augmented_hessian(double parameter)
Set value of augmented hessian parameter. If 0, than augmented Hessian is not used.
Definition: SubspaceSolverLinEig.h:119
void solve(IXSpace< R, Q, P > &xspace, const size_t nroots_max) override
Solve the subspace problem.
Definition: SubspaceSolverLinEig.h:27
void set_hermiticity(bool hermitian)
Set Hermiticity of the subspace.
Definition: SubspaceSolverLinEig.h:116
const std::vector< value_type_abs > & errors() const override
Access errors corresponding to each solution.
Definition: SubspaceSolverLinEig.h:107
int convert_verbosity(log::Verbosity verbosity)
Definition: SubspaceSolverLinEig.h:37
double m_augmented_hessian
value of augmented hessian parameter. If 0, than augmented Hessian is not used
Definition: SubspaceSolverLinEig.h:132
SubspaceSolverLinEig(std::shared_ptr< Logger > logger)
Definition: SubspaceSolverLinEig.h:25
void solve_linear_equations(IXSpace< R, Q, P > &xspace)
Definition: SubspaceSolverLinEig.h:76
const Matrix< value_type > & solutions() const override
Access solutions from the last solve() call.
Definition: SubspaceSolverLinEig.h:105
bool m_hermitian
flags the matrix as Hermitian
Definition: SubspaceSolverLinEig.h:131
size_t size() const override
Number of solutions.
Definition: SubspaceSolverLinEig.h:110
Verbosity
Different levels of logging.
Definition: Logger.h:29
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:486
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:316
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