1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ITERATIVESOLVER_HELPER_H_
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ITERATIVESOLVER_HELPER_H_
7#include <molpro/iostream.h>
8#include <molpro/linalg/array/Span.h>
9#include <molpro/linalg/scalar_traits.h>
30 std::vector<value_type>
u;
31 std::vector<value_type>
v;
42 std::span<double> eigenvalues,
const size_t dimension);
47template <
typename value_type>
50template <
typename value_type>
54template <
typename value_type>
68template <
typename value_type,
typename std::enable_if_t<!is_complex<value_type>{}, std::
nullptr_t> =
nullptr>
72template <
typename value_type,
typename std::enable_if_t<is_complex<value_type>{},
int> = 0>
77template <
typename value_type>
78void printMatrix(
const std::vector<value_type>&,
size_t rows,
size_t cols, std::string
title =
"",
79 std::ostream&
s = molpro::cout);
81template <
typename value_type,
typename std::enable_if_t<is_complex<value_type>{},
int> = 0>
83 const std::vector<value_type>& matrix,
const std::vector<value_type>&
metric,
size_t dimension,
85 std::vector<std::pair<std::size_t, value_type>>*
imag_eval_parts =
nullptr,
86 size_t nroots = std::numeric_limits<size_t>::max());
94template <
typename value_type,
typename std::enable_if_t<!is_complex<value_type>{}, std::
nullptr_t> =
nullptr>
96 const std::vector<value_type>& matrix,
const std::vector<value_type>&
metric,
size_t dimension,
98 std::vector<std::pair<std::size_t, value_type>>*
imag_eval_parts =
nullptr,
99 size_t nroots = std::numeric_limits<size_t>::max());
101template <
typename value_type,
typename std::enable_if_t<is_complex<value_type>{},
int> = 0>
103 const std::vector<value_type>& matrix,
const std::vector<value_type>&
metric,
104 const std::vector<value_type>& rhs,
size_t dimension,
size_t nroot,
108template <
typename value_type,
typename std::enable_if_t<!is_complex<value_type>{}, std::
nullptr_t> =
nullptr>
110 const std::vector<value_type>& matrix,
const std::vector<value_type>&
metric,
111 const std::vector<value_type>& rhs,
size_t dimension,
size_t nroot,
115template <
typename value_type,
typename std::enable_if_t<is_complex<value_type>{},
int> = 0>
116void solve_DIIS(std::vector<value_type>& solution,
const std::vector<value_type>& matrix,
size_t dimension,
118template <
typename value_type,
typename std::enable_if_t<!is_complex<value_type>{}, std::
nullptr_t> =
nullptr>
119void solve_DIIS(std::vector<value_type>& solution,
const std::vector<value_type>& matrix,
size_t dimension,
135 const std::vector<double>& matrix,
const std::vector<double>&
metric,
140 const std::vector<double>& matrix,
const std::vector<double>&
metric,
141 const std::vector<double>& rhs,
size_t dimension,
size_t nroot,
142 double augmented_hessian,
double svdThreshold,
int verbosity);
144extern template void solve_DIIS<double>(std::vector<double>& solution,
const std::vector<double>& matrix,
145 const size_t dimension,
double svdThreshold,
int verbosity);
155 std::string
title, std::ostream&
s);
163 std::vector<long double>& eigenvalues,
164 const std::vector<long double>& matrix,
165 const std::vector<long double>&
metric,
const size_t dimension,
170 std::vector<long double>& solution, std::vector<long double>& eigenvalues,
const std::vector<long double>& matrix,
171 const std::vector<long double>&
metric,
const std::vector<long double>& rhs,
size_t dimension,
size_t nroot,
172 long double augmented_hessian,
long double svdThreshold,
int verbosity);
175 const size_t dimension,
long double svdThreshold,
int verbosity);
181 size_t cols, std::string
title, std::ostream&
s);
188 std::vector<std::complex<double>>&
eigenvectors, std::vector<std::complex<double>>& eigenvalues,
189 const std::vector<std::complex<double>>& matrix,
const std::vector<std::complex<double>>&
metric,
194 std::vector<std::complex<double>>& solution, std::vector<std::complex<double>>& eigenvalues,
195 const std::vector<std::complex<double>>& matrix,
const std::vector<std::complex<double>>&
metric,
196 const std::vector<std::complex<double>>& rhs,
size_t dimension,
size_t nroot,
double augmented_hessian,
200 const std::vector<std::complex<double>>& matrix,
201 const size_t dimension,
double svdThreshold,
int verbosity);
Non-owning container taking a pointer to the data buffer and its size and exposing routines for itera...
Definition Span.h:31
4-parameter interpolation of a 1-dimensional function given two points for which function values and ...
Definition helper.h:14
template void eigenproblem< double >(std::vector< double > &eigenvectors, std::vector< double > &eigenvalues, const std::vector< double > &matrix, const std::vector< double > &metric, const size_t dimension, bool hermitian, double svdThreshold, int verbosity, std::vector< std::pair< std::size_t, double > > *imag_eval_parts, size_t nroots)
template void printMatrix< double >(const std::vector< double > &, size_t rows, size_t cols, std::string title, std::ostream &s)
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:844
template void solve_DIIS< double >(std::vector< double > &solution, const std::vector< double > &matrix, const size_t dimension, double svdThreshold, int verbosity)
int eigensolver_lapacke_dsyev(std::span< const double > matrix, std::span< double > eigenvectors, std::span< double > eigenvalues, const size_t dimension)
Eigen-decomposition of a real symmetric matrix in double precision.
Definition helper-implementation.h:153
template size_t get_rank< value_type >(std::span< const value_type > eigenvalues, value_type threshold)
void solve_DIIS(std::vector< value_type > &solution, const std::vector< value_type > &matrix, size_t dimension, real_type_t< value_type > svdThreshold, int verbosity=0)
Definition helper-implementation.h:930
template size_t get_rank< long double >(std::span< const long double > eigenvalues, long double threshold)
template void solve_LinearEquations< double >(std::vector< double > &solution, std::vector< double > &eigenvalues, const std::vector< double > &matrix, const std::vector< double > &metric, const std::vector< double > &rhs, size_t dimension, size_t nroot, double augmented_hessian, double svdThreshold, int verbosity)
template void printMatrix< long double >(const std::vector< long double > &, size_t rows, size_t cols, std::string title, std::ostream &s)
std::list< SVD< value_type > > svd_system(size_t nrows, size_t ncols, const array::Span< value_type > &m, real_type_t< value_type > threshold, bool hermitian=false, bool reduce_to_rank=false)
Performs singular value decomposition and returns SVD objects for singular values less than threshold...
Definition helper-implementation.h:268
template void solve_DIIS< long double >(std::vector< long double > &solution, const std::vector< long double > &matrix, const size_t dimension, long double svdThreshold, int verbosity)
template void solve_LinearEquations< long double >(std::vector< long double > &solution, std::vector< long double > &eigenvalues, const std::vector< long double > &matrix, const std::vector< long double > &metric, const std::vector< long double > &rhs, size_t dimension, size_t nroot, long double augmented_hessian, long double svdThreshold, int verbosity)
template void eigenproblem< long double >(std::vector< long double > &eigenvectors, std::vector< long double > &eigenvalues, const std::vector< long double > &matrix, const std::vector< long double > &metric, const size_t dimension, bool hermitian, long double svdThreshold, int verbosity, std::vector< std::pair< std::size_t, long double > > *imag_eval_parts, size_t nroots)
size_t get_rank(std::span< const value_type > eigenvalues, value_type threshold)
Definition helper-implementation.h:171
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, size_t nroots=std::numeric_limits< size_t >::max())
Definition helper-implementation.h:431
void printMatrix(const std::vector< value_type > &, size_t rows, size_t cols, std::string title="", std::ostream &s=molpro::cout)
Definition helper-implementation.h:280
template size_t get_rank< double >(std::span< const double > eigenvalues, double threshold)
real_type_t< T > real_part(const T &x)
The real part of a scalar; the value itself for a real type.
Definition scalar_traits.h:58
T conjugate(const T &x)
Complex conjugate, staying within the scalar type; the identity for a real type.
Definition scalar_traits.h:47
typename real_type< T >::type real_type_t
The real type underlying T, i.e. T itself for a real type and U for std::complex<U>.
Definition scalar_traits.h:43
real_type_t< T > imaginary_part(const T &x)
The imaginary part of a scalar; zero for a real type.
Definition scalar_traits.h:68
real_type_t< value_type > precision_scaled(double tolerance_for_double)
Rescale a tolerance that was calibrated for IEEE double precision to the working precision.
Definition scalar_traits.h:85
Definition scalar_traits.h:19
Stores a singular value and corresponding left and right singular vectors.
Definition helper.h:27
std::vector< value_type > v
right singular vector
Definition helper.h:31
T value_type
Definition helper.h:28
value_type value
Definition helper.h:29
std::vector< value_type > u
left singular vector
Definition helper.h:30
The real type underlying a (possibly complex) scalar type.
Definition scalar_traits.h:26