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>{};
69 auto [
first,
last] = std::ranges::remove_if(
73 m_logger->info(
"Complex eigenvalue pair split up due to truncation to requested number of roots");
78 m_errors.assign(
size(), std::numeric_limits<value_type_abs>::max());
81 m_logger->info(
"The following eigenvalues turned out to be complex-valued: ",
83 std::ranges::views::transform([](
const auto&
pair) {
return pair.first + 1; }));
84 m_logger->data_dump(
"imaginary parts of eigenvalues = ",
94 m_logger->trace(
"SubspaceSolverLinEig::solve_linear_equations");
101 const auto dim =
h.rows();
103 auto solution = std::vector<value_type>{};
110 m_errors.assign(
size(), std::numeric_limits<value_type_abs>::max());
119 for (
size_t i = 0;
i <
roots.size(); ++
i)
Full subspace.
Definition IXSpace.h:19
SubspaceData< value_type > data
Equation data in the subspace.
Definition IXSpace.h:28
Matrix container that allows simple data access, slicing, copying and resizing without loosing data.
Definition Matrix.h:32
Slice slice(coord_type upper_left, coord_type bottom_right)
Access a rectangular slice of the matrix.
Definition Matrix.h:101
void resize(const coord_type &dims)
Resize the matrix. The old data is preserved and any new rows/cols are zeroed.
Definition Matrix.h:130
index_type rows() const
Definition Matrix.h:169
Solves subspace problem for linear eigenvalues and system of linear equations.
Definition SubspaceSolverLinEig.h:17
value_type_abs get_augmented_hessian()
Definition SubspaceSolverLinEig.h:139
value_type_abs m_augmented_hessian
value of augmented hessian parameter. If 0, than augmented Hessian is not used
Definition SubspaceSolverLinEig.h:154
std::vector< value_type_abs > m_errors
errors in subspace solutions
Definition SubspaceSolverLinEig.h:145
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:118
void set_logger(std::shared_ptr< Logger > logger) override
Definition SubspaceSolverLinEig.h:131
void set_error(int root, value_type_abs error) override
Set error value for solution root
Definition SubspaceSolverLinEig.h:117
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, rescaled from double to the working precis...
Definition SubspaceSolverLinEig.h:150
std::vector< value_type > m_eigenvalues
eigenvalues
Definition SubspaceSolverLinEig.h:143
bool get_hermiticity()
Definition SubspaceSolverLinEig.h:136
typename ISubspaceSolver< RT, QT, PT >::Q Q
Definition SubspaceSolverLinEig.h:22
Matrix< value_type > m_solutions
solution matrix with row vectors
Definition SubspaceSolverLinEig.h:142
std::shared_ptr< Logger > m_logger
Definition SubspaceSolverLinEig.h:146
const std::vector< value_type > & eigenvalues() const override
Access eigenvalues from the last solve() call.
Definition SubspaceSolverLinEig.h:124
std::vector< std::pair< std::size_t, value_type > > m_imag_eigval_comps
eigenvalues
Definition SubspaceSolverLinEig.h:144
void set_augmented_hessian(value_type_abs parameter)
Set value of augmented hessian parameter. If 0, than augmented Hessian is not used.
Definition SubspaceSolverLinEig.h:138
typename ISubspaceSolver< RT, QT, PT >::value_type value_type
Definition SubspaceSolverLinEig.h:19
typename ISubspaceSolver< RT, QT, PT >::P P
Definition SubspaceSolverLinEig.h:23
void solve(IXSpace< R, Q, P > &xspace, const size_t nroots_max) override
Solve the subspace problem.
Definition SubspaceSolverLinEig.h:27
const std::vector< std::pair< std::size_t, value_type > > & imag_eigval_components() const
Definition SubspaceSolverLinEig.h:125
void set_hermiticity(bool hermitian)
Set Hermiticity of the subspace.
Definition SubspaceSolverLinEig.h:135
const std::vector< value_type_abs > & errors() const override
Access errors corresponding to each solution.
Definition SubspaceSolverLinEig.h:126
int convert_verbosity(log::Verbosity verbosity)
Definition SubspaceSolverLinEig.h:37
SubspaceSolverLinEig(std::shared_ptr< Logger > logger)
Definition SubspaceSolverLinEig.h:25
void solve_linear_equations(IXSpace< R, Q, P > &xspace)
Definition SubspaceSolverLinEig.h:93
const Matrix< value_type > & solutions() const override
Access solutions from the last solve() call.
Definition SubspaceSolverLinEig.h:123
typename ISubspaceSolver< RT, QT, PT >::R R
Definition SubspaceSolverLinEig.h:21
bool m_hermitian
Definition SubspaceSolverLinEig.h:152
size_t size() const override
Number of solutions.
Definition SubspaceSolverLinEig.h:129
Verbosity
Different levels of logging.
Definition Logger.h:29
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, real_type_t< value_type > svdThreshold, int verbosity, std::vector< std::pair< std::size_t, value_type > > *imag_eval_parts=nullptr)
Definition helper-implementation.h:377
std::unique_ptr< LinearEigensystem< R, Q, P > > create_LinearEigensystem(const LinearEigensystemOptions &options, const std::shared_ptr< ArrayHandlers< R, Q, P > > &handlers=std::make_shared< molpro::linalg::itsolv::ArrayHandlers< R, Q, P > >())
Definition SolverFactory.h:111
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, real_type_t< value_type > augmented_hessian, real_type_t< value_type > svdThreshold, int verbosity)
Definition helper-implementation.h:740
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