iterative-solver 0.0
 
Loading...
Searching...
No Matches
LinearEigensystemDavidson.h
1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_LINEAREIGENSYSTEMDAVIDSON_H
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_LINEAREIGENSYSTEMDAVIDSON_H
3#include <molpro/Profiler.h>
4#include <molpro/linalg/itsolv/CastOptions.h>
5#include <molpro/linalg/itsolv/DavidsonCommon.h>
6#include <molpro/linalg/itsolv/IterativeSolverTemplate.h>
7#include <molpro/linalg/itsolv/Logger.h>
8#include <molpro/linalg/itsolv/helper.h>
9#include <molpro/linalg/itsolv/subspace/SubspaceSolverLinEig.h>
10#include <molpro/linalg/itsolv/subspace/XSpace.h>
11
12#include <algorithm>
13#include <cassert>
14#include <cmath>
15#include <format>
16#include <iterator>
17#include <map>
18#include <optional>
19#include <span>
20#include <stdexcept>
21#include <string>
22
23namespace molpro::linalg::itsolv {
24
25namespace log {
26
30template <typename Scalar>
32 static constexpr std::string_view name = "ComplexRootsDavidson";
33 struct Payload {
35 std::span<const std::pair<std::size_t, Scalar>> roots;
36 };
38 static std::string format(const Payload& p) {
39 std::vector<std::pair<std::size_t, Scalar>> one_based(p.roots.begin(), p.roots.end());
40 for (auto& pair : one_based)
41 ++pair.first;
42 return stringify(one_based);
43 }
44};
45
46}
47
59template <class R, class Q = R, class P = std::map<size_t, typename R::value_type>>
60class LinearEigensystemDavidson : public DavidsonCommon<LinearEigensystem, R, Q, P> {
61public:
64 using typename SolverTemplate::scalar_type;
65 using typename SolverTemplate::value_type;
66 using typename SolverTemplate::value_type_abs;
67
70 const std::shared_ptr<Logger>& logger_ = std::make_shared<Logger>())
72
77
78 void finalize() override {
80 return;
81 } else {
82 auto subspace_solver =
83 std::dynamic_pointer_cast<subspace::SubspaceSolverLinEig<R, Q, P>>(this->m_subspace_solver);
85 auto imag_eigval_components = subspace_solver->imag_eigval_components();
86 if (imag_eigval_components.empty()) {
87 return;
88 }
89
91 this->m_logger->template emit<Ctx>(
93 "The following roots are complex-valued. Associated eigenvectors are the real and imaginary part "
94 "of the pairs and the imaginary parts of the eigenvalues are ",
95 [&] { return typename Ctx::Payload{imag_eigval_components}; });
96
97 const auto nroots = subspace_solver->size();
98 if (const auto partner = subspace_solver->complex_partner(nroots - 1); partner && *partner >= nroots)
99 this->m_logger->warn(std::format("The complex conjugate partner of root {} is not among the requested roots, so "
100 "only the real part of its eigenvector is available",
101 nroots));
102 }
103 }
104
105 std::vector<scalar_type> eigenvalues() const override { return this->m_subspace_solver->eigenvalues(); }
106
107 virtual std::vector<scalar_type> working_set_eigenvalues() const override {
108 auto eval = std::vector<scalar_type>{};
109 for (auto i : this->working_set()) {
110 eval.push_back(i < this->m_subspace_solver->eigenvalues().size() ? this->m_subspace_solver->eigenvalues().at(i)
111 : 0);
112 }
113 return eval;
114 }
115
116 void report(std::ostream& cout, bool endl = true) const override {
119 cout << "errors " << std::scientific;
120 auto& err = this->m_errors;
121 std::copy(begin(err), end(err), std::ostream_iterator<scalar_type>(cout, ", "));
122 cout << std::endl;
123 cout << "eigenvalues ";
124 auto ev = eigenvalues();
125 cout << std::fixed << std::setprecision(14);
126 std::copy(begin(ev), end(ev), std::ostream_iterator<scalar_type>(cout, ", "));
127 if (endl)
128 cout << std::endl;
129 }
130
131 void set_options(const Options& options) override {
133 }
134
135 std::shared_ptr<Options> get_options() const override {
137 }
138
139protected:
140 std::vector<value_type> values() const override { return this->m_subspace_solver->eigenvalues(); }
141
142 void construct_residual(const std::vector<int>& roots, const CVecRef<R>& params, const VecRef<R>& actions,
144 construct_residual(roots, params, actions, metric_solutions, nullptr);
145 }
146
154 void solution_with_errors(const std::vector<int>& roots, const VecRef<R>& parameters, const VecRef<R>& residual,
155 const VecRef<R>& scratch, const std::vector<value_type_abs>& solution_norms,
156 std::vector<value_type_abs>& errors) override {
157 auto truncated_partner_residual_norm = std::optional<value_type_abs>{};
158 this->solution_impl(roots, parameters, residual, scratch, [&](const auto&... args) {
160 });
161 SolverTemplate::compute_errors(roots, cwrap(parameters), cwrap(residual), solution_norms, errors);
163 return;
164 auto subspace_solver = std::dynamic_pointer_cast<subspace::SubspaceSolverLinEig<R, Q, P>>(this->m_subspace_solver);
166 const auto nroots = subspace_solver->size();
168 if (!solution_norms.empty())
169 // as in SolverTemplate::compute_errors(), the error of the partner of unit length
171 this->m_xspace->data.at(subspace::EqnData::S))
172 [subspace_solver->complex_partner(nroots - 1).value()];
173 auto& error = errors.at(std::ranges::distance(roots.begin(), std::ranges::find(roots, int(nroots) - 1)));
174 error = std::sqrt(error * error + partner_error * partner_error);
175 }
176
182 void construct_residual(const std::vector<int>& roots, const CVecRef<R>& params, const VecRef<R>& actions,
184 std::optional<value_type_abs>* truncated_partner_residual_norm) {
185 if (roots.empty())
186 return;
187 auto prof = this->profiler()->push("itsolv::construct_residual");
188 assert(params.size() >= roots.size());
189 const auto& eigvals = eigenvalues();
190
191 auto subspace_solver = std::dynamic_pointer_cast<subspace::SubspaceSolverLinEig<R, Q, P>>(this->m_subspace_solver);
193 const auto& imag_eigval_components = subspace_solver->imag_eigval_components();
194
195 // With a metric M, the residual contains M x rather than x for each solution x. M x is given in metric_solutions
196 // where the metric is applied on the fly, and otherwise assembled from the stored actions of the metric on the Q
197 // and D spaces and the action of the metric on the P space. The coefficients are collected in these matrices.
198 const auto& xspace = *this->m_xspace;
199 const bool metric = xspace.metric_kind() != MetricKind::Identity;
200 const bool on_the_fly = metric && xspace.metric_storage() == MetricStorage::OnTheFly;
201 const bool stored = metric && !on_the_fly;
202 const auto& dims = xspace.dimensions();
203 const auto& solutions = this->m_subspace_solver->solutions();
204 using coefficient_matrix = std::decay_t<decltype(solutions)>;
205 // the coefficients of the Q and D vectors are in one matrix, with the Q vectors first
206 coefficient_matrix mp_coeff({stored ? dims.nP : 0, roots.size()}),
207 mqd_coeff({stored ? dims.nQ + dims.nD : 0, roots.size()}),
208 mx_coeff({on_the_fly ? roots.size() : 0, roots.size()});
209 // adds weight times the action of the metric on the solution params[k], whose coefficients are in the given row of
210 // coefficients, to the residual actions[i]
211 auto add_metric_solution = [&](const scalar_type weight, const coefficient_matrix& coefficients, const int row,
212 const size_t k, const size_t i) {
213 if (on_the_fly) {
214 mx_coeff(k, i) += weight;
215 } else {
216 for (size_t j = 0; j < dims.nP; ++j)
217 mp_coeff(j, i) += weight * coefficients(row, dims.oP() + j);
218 for (size_t j = 0; j < dims.nQ; ++j)
219 mqd_coeff(j, i) += weight * coefficients(row, dims.oQ() + j);
220 for (size_t j = 0; j < dims.nD; ++j)
221 mqd_coeff(dims.nQ + j, i) += weight * coefficients(row, dims.oD() + j);
222 }
223 };
224
225 for (size_t i = 0; i < roots.size(); ++i) {
226 if (metric)
227 add_metric_solution(-eigvals.at(roots[i]), solutions, roots[i], i, i);
228 else
229 this->m_handlers->rr().axpy(-eigvals.at(roots[i]), params.at(i), actions.at(i));
230
231 auto it = std::ranges::find(imag_eigval_components, roots[i], [](const auto& pair) { return pair.first; });
232
233 if (it != imag_eigval_components.end()) {
234 // Ref.: https://doi.org/10.1063/1.2755681 (Appendix)
235 // The idea is the following: We make use of the fact that the real and imaginary parts of the
236 // eigenvectors belonging to the complex root pair are spanned by the same basis. This allows
237 // us to split the associated residual vectors into a part corresponding to the real and a part
238 // corresponding to the imaginary part as well. The actual (complex-valued) residual can then
239 // always be reconstructed from this and therefore we don't lose any information. The formulas are
240 // |(R_real)_i> = sum_j [ (|A_j> - (e_real)_i |b_j>) (c_real)_{ji} + (e_imag) |b_j> (c_imag)_{ji} ]
241 // |(R_imag)_i> = sum_j [ (|A_j> - (e_real)_i |b_j>) (c_imag)_{ji} - (e_imag) |b_j> (c_real)_{ji} ]
242 // where |A_j> is the j-th action and |b_j> the j-th trial vector. e are the complex conjugate
243 // eigenvalues and c the associated eigenvectors.
244 // Note: At this point, params and actions already contain the vectors transformed into the
245 // eigenbasis (aka.: multiplied with c). Due to the way we process these complex-valued vectors,
246 // the first vector in a pair is the one that has been transformed with the real and the second
247 // with the imaginary part of c.
248 // The above code has already dealt with the bulk of the necessary expression and we only need
249 // to add the part with the imaginary components of the eigenvalue pair, for which the vector of
250 // the partner root is used.
251 // Note: The minus sign in above expression is implicitly taken into account as the
252 // imaginary parts of the complex conjugate eigenvalue pair has flipped signs
253 const auto partner = subspace_solver->complex_partner(roots[i]).value();
254 const auto root_it = std::ranges::find(roots, int(partner));
255 // the partner's vector, or the action of the metric on it applied on the fly, if it is assembled
256 auto partner_param = std::optional<R>{};
257 if (root_it != roots.end() && (!metric || on_the_fly)) {
258 const auto k = std::ranges::distance(roots.begin(), root_it);
259 if (metric)
260 add_metric_solution(it->second, solutions, int(partner), k, i);
261 else
262 this->m_handlers->rr().axpy(it->second, params.at(k), actions.at(i));
263 } else if (stored) {
264 // The partner's coefficients are among the retained solutions also if it is not among roots
265 if (partner >= subspace_solver->retained_solutions().rows())
266 throw std::logic_error("The complex conjugate partner of a root is not among the retained solutions");
267 add_metric_solution(it->second, subspace_solver->retained_solutions(), int(partner), 0, i);
268 } else {
269 // The partner is not among roots, or was truncated away, so its vector is assembled from the subspace
270 if (partner >= subspace_solver->retained_solutions().rows())
271 throw std::logic_error("The complex conjugate partner of a root is not among the retained solutions");
272 partner_param.emplace(this->m_handlers->rr().copy(actions.at(i)));
273 this->construct_solutions({int(partner)}, subspace_solver->retained_solutions(), wrap_arg(*partner_param));
274 if (on_the_fly)
276 this->m_handlers->rr().axpy(it->second, *partner_param, actions.at(i));
277 }
279 // The residual of the truncated partner p is the imaginary part of the residual of this root x. It is
280 // A p - e M p - f M x, where e and f are the real and imaginary parts of the eigenvalue of x, the imaginary
281 // part of the eigenvalue of p being -f, and M is the identity without a metric.
282 const auto& retained = subspace_solver->retained_solutions();
283 auto partner_residual = this->m_handlers->rr().copy(actions.at(i));
285 if (stored) {
286 auto metric_action = this->m_handlers->rr().copy(actions.at(i));
288 this->m_handlers->rr().axpy(-eigvals.at(roots[i]), metric_action, partner_residual);
289 construct_subspace_metric_action(retained, roots[i], metric_action);
290 this->m_handlers->rr().axpy(-it->second, metric_action, partner_residual);
291 } else {
292 this->m_handlers->rr().axpy(-eigvals.at(roots[i]), *partner_param, partner_residual);
293 if (!metric) {
294 this->m_handlers->rr().axpy(-it->second, params.at(i), partner_residual);
295 } else if (!metric_solutions.r.empty()) {
296 this->m_handlers->rr().axpy(-it->second, metric_solutions.r.at(i), partner_residual);
297 } else {
298 assert(metric_solutions.q.size() > i);
299 this->m_handlers->rq().axpy(-it->second, metric_solutions.q.at(i), partner_residual);
300 }
301 }
303 }
304 }
305 }
306 const auto residuals = wrap(actions.begin(), actions.begin() + roots.size());
307 if (stored) {
308 if (dims.nP > 0) {
309 using VectorP = typename SolverTemplate::VectorP;
310 auto pvectors = std::vector<VectorP>(roots.size(), VectorP(dims.nP));
311 for (size_t i = 0; i < roots.size(); ++i)
312 for (size_t j = 0; j < dims.nP; ++j)
313 pvectors[i][j] = mp_coeff(j, i);
314 this->m_apply_metric_p(pvectors, xspace.cparamsp(), residuals);
315 }
316 // one pass over the residuals for the actions of the metric on the Q and D vectors
317 auto qd_metric_actions = xspace.cmetric_actionsq();
318 const auto d_metric_actions = xspace.cmetric_actionsd();
320 this->m_handlers->rq().gemm_outer(mqd_coeff, qd_metric_actions, residuals);
321 } else if (on_the_fly && !metric_solutions.r.empty()) {
322 this->m_handlers->rr().gemm_outer(mx_coeff, metric_solutions.r, residuals);
323 } else if (on_the_fly) {
324 this->m_handlers->rq().gemm_outer(mx_coeff, metric_solutions.q, residuals);
325 }
326 }
327
334 void combine_errors() override {
335 auto subspace_solver = std::dynamic_pointer_cast<subspace::SubspaceSolverLinEig<R, Q, P>>(this->m_subspace_solver);
337 const auto& errors = subspace_solver->errors();
338 for (size_t root = 0; root < subspace_solver->size(); ++root) {
339 const auto partner = subspace_solver->complex_partner(root);
341 continue;
342 const auto error = std::sqrt(errors[root] * errors[root] + errors[*partner] * errors[*partner]);
343 subspace_solver->set_error(int(root), error);
344 subspace_solver->set_error(int(*partner), error);
345 }
346 }
347
349 void apply_metric(R& param) {
350 auto metric_action = this->m_handlers->rr().copy(param);
351 this->m_apply_metric(cwrap_arg(param), wrap_arg(metric_action));
352 this->m_handlers->rr().copy(param, metric_action);
353 }
354
356 void construct_subspace_metric_action(const subspace::Matrix<scalar_type>& solutions, int row, R& metric_action) {
357 const auto& dims = this->m_xspace->dimensions();
358 assert(solutions.cols() == dims.nX());
359 util::construct_solutions(wrap_arg(metric_action), {row}, solutions, CVecRef<P>{},
360 this->m_xspace->cmetric_actionsq(), this->m_xspace->cmetric_actionsd(), dims.oP(),
361 dims.oQ(), dims.oD(), this->m_handlers->rr(), this->m_handlers->rp(),
362 this->m_handlers->rq());
363 if (dims.nP > 0)
364 this->m_apply_metric_p(detail::construct_vectorP({row}, solutions, dims.oP(), dims.nP),
365 this->m_xspace->cparamsp(), wrap_arg(metric_action));
366 }
367};
368
369} // namespace molpro::linalg::itsolv
370
371#endif // LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_LINEAREIGENSYSTEMDAVIDSON_H
Class, containing a collection of array handlers used in IterativeSolver Provides a Builder sub-class...
Definition ArrayHandlers.h:25
Implementation shared by the linear Davidson solvers, LinearEigensystemDavidson and LinearEquationsDa...
Definition DavidsonCommon.h:35
void set_davidson_options(const Options &options, const DavidsonOptions &opt)
Sets the general options and those of the Davidson solvers, after checking them.
Definition DavidsonCommon.h:155
Implements IterativeSolver interface that is common to all solvers.
Definition IterativeSolverTemplate.h:187
fapply_on_p_type m_apply_metric_p
adds the action of the metric on the P space, if its actions are stored
Definition IterativeSolverTemplate.h:1230
std::shared_ptr< subspace::IXSpace< R, Q, P > > m_xspace
manages the subspace and associated data
Definition IterativeSolverTemplate.h:1210
std::shared_ptr< ArrayHandlers< R, Q, P > > m_handlers
Array handlers.
Definition IterativeSolverTemplate.h:1209
virtual void compute_errors(const std::vector< int > &roots, const CVecRef< R > &params, const CVecRef< R > &residuals, const std::vector< value_type_abs > &solution_norms, std::vector< value_type_abs > &errors)
Computes the errors of roots, given their parameters and residuals; by default the norms of the resid...
Definition IterativeSolverTemplate.h:888
void construct_actions(const std::vector< int > &rows, const subspace::Matrix< value_type > &solutions, const VecRef< R > &actions)
Constructs the actions on the subspace vectors with the coefficients in the given rows of solutions.
Definition IterativeSolverTemplate.h:783
std::shared_ptr< subspace::ISubspaceSolver< R, Q, P > > m_subspace_solver
solves the subspace problem
Definition IterativeSolverTemplate.h:1211
std::vector< value_type_abs > m_errors
errors from the most recent solution
Definition IterativeSolverTemplate.h:1212
void solution_impl(const std::vector< int > &roots, const VecRef< R > &parameters, const VecRef< R > &residual, const VecRef< R > &scratch)
Implements solution()
Definition IterativeSolverTemplate.h:717
void construct_solutions(const std::vector< int > &rows, const subspace::Matrix< value_type > &solutions, const VecRef< R > &parameters)
Constructs the subspace vectors with the coefficients in the given rows of solutions.
Definition IterativeSolverTemplate.h:766
const std::shared_ptr< molpro::profiler::Profiler > & profiler() const override
Definition IterativeSolverTemplate.h:434
const std::vector< value_type_abs > & errors() const override
Definition IterativeSolverTemplate.h:353
void report() const override
Definition IterativeSolverTemplate.h:384
const std::vector< int > & working_set() const override
Definition IterativeSolverTemplate.h:314
std::shared_ptr< Logger > m_logger
logger
Definition IterativeSolverTemplate.h:1220
fapply_metric_type m_apply_metric
applies the metric on the fly, if its actions are not stored
Definition IterativeSolverTemplate.h:1227
One specific implementation of LinearEigensystem using Davidson's algorithm with modifications to man...
Definition LinearEigensystemDavidson.h:60
void finalize() override
Definition LinearEigensystemDavidson.h:78
std::vector< value_type > values() const override
The values of the current solutions, whose changes between iterations are the value errors.
Definition LinearEigensystemDavidson.h:140
void apply_metric(R &param)
Replaces param by the action of the metric on it, with the metric applied on the fly.
Definition LinearEigensystemDavidson.h:349
std::vector< scalar_type > eigenvalues() const override
Definition LinearEigensystemDavidson.h:105
void construct_residual(const std::vector< int > &roots, const CVecRef< R > &params, const VecRef< R > &actions, const detail::MetricSolutions< R, Q > &metric_solutions, std::optional< value_type_abs > *truncated_partner_residual_norm)
Constructs residual for given roots provided their parameters and actions.
Definition LinearEigensystemDavidson.h:182
void set_options(const Options &options) override
Definition LinearEigensystemDavidson.h:131
void construct_residual(const std::vector< int > &roots, const CVecRef< R > &params, const VecRef< R > &actions, const detail::MetricSolutions< R, Q > &metric_solutions) override
Constructs residual for given roots provided their parameters and actions.
Definition LinearEigensystemDavidson.h:142
void combine_errors() override
The error of both members of a complex pair is the norm of their complex residual.
Definition LinearEigensystemDavidson.h:334
bool supports_metric(MetricKind kind) const override
Supports generalised eigenproblems A v = lambda M v with a Hermitian, positive definite metric M.
Definition LinearEigensystemDavidson.h:74
void report(std::ostream &cout, bool endl=true) const override
Definition LinearEigensystemDavidson.h:116
virtual std::vector< scalar_type > working_set_eigenvalues() const override
Definition LinearEigensystemDavidson.h:107
LinearEigensystemDavidson(const std::shared_ptr< ArrayHandlers< R, Q, P > > &handlers=std::make_shared< molpro::linalg::itsolv::ArrayHandlers< R, Q, P > >(), const std::shared_ptr< Logger > &logger_=std::make_shared< Logger >())
Definition LinearEigensystemDavidson.h:68
std::shared_ptr< Options > get_options() const override
Definition LinearEigensystemDavidson.h:135
void solution_with_errors(const std::vector< int > &roots, const VecRef< R > &parameters, const VecRef< R > &residual, const VecRef< R > &scratch, const std::vector< value_type_abs > &solution_norms, std::vector< value_type_abs > &errors) override
Constructs the parameters and residuals of roots and their errors.
Definition LinearEigensystemDavidson.h:154
void construct_subspace_metric_action(const subspace::Matrix< scalar_type > &solutions, int row, R &metric_action)
Constructs in metric_action the action of the metric on the subspace vector with the given row of coe...
Definition LinearEigensystemDavidson.h:356
Interface for a specific iterative solver, it can add special member functions or variables.
Definition IterativeSolver.h:770
Matrix container that allows simple data access, slicing, copying and resizing without loosing data.
Definition Matrix.h:32
index_type cols() const
Definition Matrix.h:170
Restores the format flags and precision of a stream when it goes out of scope.
Definition util.h:156
std::vector< std::vector< T > > construct_vectorP(const std::vector< int > &roots, const subspace::Matrix< T > &solutions, const size_t oP, const size_t nP)
Definition IterativeSolverTemplate.h:47
std::string stringify(const T &t, std::size_t precision=default_precision)
Converts the given object into a string.
Definition Logger.h:178
std::vector< real_type_t< T > > solution_norms(const Matrix< T > &solutions, const Matrix< T > &overlap)
The Euclidean norms of the solutions x_i = sum_j c_ij b_j, from their subspace coefficients c (one ro...
Definition util.h:82
void construct_solutions(const VecRef< R > &params, const std::vector< int > &roots, const subspace::Matrix< value_type > &solutions, const CVecRef< P > &pparams, const CVecRef< Q > &qparams, const CVecRef< Q > &dparams, size_t oP, size_t oQ, size_t oD, array::ArrayHandler< R, R > &handler_rr, array::ArrayHandler< R, P > &handler_rp, array::ArrayHandler< R, Q > &handler_rq)
Construct solutions.
Definition util.h:82
auto norm(array::ArrayHandler< R, R > &handler, const std::type_identity_t< R > &x) -> typename array::ArrayHandler< R, R >::value_type_abs
The length of x, sqrt(|<x|x>|), which is real also for complex values.
Definition util.h:21
4-parameter interpolation of a 1-dimensional function given two points for which function values and ...
Definition helper.h:14
auto cwrap(ForwardIt begin, ForwardIt end)
Takes a begin and end iterators and returns a vector of references to each element.
Definition wrap.h:52
auto wrap_arg(T &&arg, S &&... args) -> std::enable_if_t< std::conjunction_v< std::is_same< decay_t< T >, decay_t< S > >... >, VecRef< decay_t< T > > >
Constructs a vector of reference wrappers with provided arguments.
Definition wrap.h:135
auto cwrap_arg(T &&arg, S &&... args) -> std::enable_if_t< std::conjunction_v< std::is_same< decay_t< T >, decay_t< S > >... >, CVecRef< decay_t< T > > >
Constructs a vector of const reference wrappers with provided arguments.
Definition wrap.h:149
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
auto wrap(ForwardIt begin, ForwardIt end)
Takes a begin and end iterators and returns a vector of references to each element.
Definition wrap.h:32
std::vector< std::reference_wrapper< const A > > CVecRef
Definition wrap.h:14
@ OnTheFly
the metric is applied to the solutions whenever residuals are constructed
std::vector< std::reference_wrapper< A > > VecRef
Definition wrap.h:11
MetricKind
The kind of metric M of a generalised problem, such as the eigenproblem A v = lambda M v.
Definition Metric.h:13
@ HermitianPositiveDefinite
Hermitian and positive definite, e.g. the overlap matrix of a non-orthogonal basis.
@ Identity
M = 1, i.e. no metric.
const std::shared_ptr< const molpro::Options > options()
Get the Options object associated with iterative-solver.
Definition linalg_options.cpp:4
Definition scalar_traits.h:19
static std::shared_ptr< LinearEigensystemDavidsonOptions > LinearEigensystem(const std::shared_ptr< Options > &options)
Definition CastOptions.h:39
Access point for different options in iterative solvers.
Definition Options.h:20
The actions of a metric applied on the fly on solutions, in R vectors or, if there are not enough of ...
Definition IterativeSolverTemplate.h:40
CVecRef< R > r
Definition IterativeSolverTemplate.h:41
CVecRef< Q > q
Definition IterativeSolverTemplate.h:42
Definition LinearEigensystemDavidson.h:33
std::span< const std::pair< std::size_t, Scalar > > roots
pairs of (0-based) root index and imaginary part of the eigenvalue, one per complex root
Definition LinearEigensystemDavidson.h:35
Definition LinearEigensystemDavidson.h:31
static constexpr std::string_view name
Definition LinearEigensystemDavidson.h:32
static std::string format(const Payload &p)
Prints 1-based root indices.
Definition LinearEigensystemDavidson.h:38