1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ITERATIVESOLVER_HELPER_H_
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ITERATIVESOLVER_HELPER_H_
6#include <molpro/iostream.h>
7#include <molpro/linalg/array/Span.h>
23 std::vector<value_type>
u;
24 std::vector<value_type>
v;
28 std::span<double> eigenvalues,
const size_t dimension);
32template <
typename value_type>
33size_t get_rank(std::vector<value_type> eigenvalues, value_type threshold);
35template <
typename value_type>
47template <
typename value_type,
typename std::enable_if_t<!is_complex<value_type>{}, std::
nullptr_t> =
nullptr>
49 bool hermitian =
false,
bool reduce_to_rank =
false);
50template <
typename value_type,
typename std::enable_if_t<is_complex<value_type>{},
int> = 0>
52 bool hermitian =
false,
bool reduce_to_rank =
false);
54template <
typename value_type>
55void printMatrix(
const std::vector<value_type>&,
size_t rows,
size_t cols, std::string title =
"",
56 std::ostream& s = molpro::cout);
58template <
typename value_type,
typename std::enable_if_t<is_complex<value_type>{},
int> = 0>
59void eigenproblem(std::vector<value_type>& eigenvectors, std::vector<value_type>& eigenvalues,
60 const std::vector<value_type>& matrix,
const std::vector<value_type>& metric,
size_t dimension,
61 bool hermitian,
double svdThreshold,
int verbosity,
bool condone_complex);
63template <
typename value_type,
typename std::enable_if_t<!is_complex<value_type>{}, std::
nullptr_t> =
nullptr>
64void eigenproblem(std::vector<value_type>& eigenvectors, std::vector<value_type>& eigenvalues,
65 const std::vector<value_type>& matrix,
const std::vector<value_type>& metric,
size_t dimension,
66 bool hermitian,
double svdThreshold,
int verbosity,
bool condone_complex);
68template <
typename value_type,
typename std::enable_if_t<is_complex<value_type>{},
int> = 0>
70 const std::vector<value_type>& matrix,
const std::vector<value_type>& metric,
71 const std::vector<value_type>& rhs,
size_t dimension,
size_t nroot,
double augmented_hessian,
72 double svdThreshold,
int verbosity);
74template <
typename value_type,
typename std::enable_if_t<!is_complex<value_type>{}, std::
nullptr_t> =
nullptr>
76 const std::vector<value_type>& matrix,
const std::vector<value_type>& metric,
77 const std::vector<value_type>& rhs,
size_t dimension,
size_t nroot,
double augmented_hessian,
78 double svdThreshold,
int verbosity);
80template <
typename value_type,
typename std::enable_if_t<is_complex<value_type>{},
int> = 0>
81void solve_DIIS(std::vector<value_type>& solution,
const std::vector<value_type>& matrix,
size_t dimension,
82 double svdThreshold,
int verbosity = 0);
83template <
typename value_type,
typename std::enable_if_t<!is_complex<value_type>{}, std::
nullptr_t> =
nullptr>
84void solve_DIIS(std::vector<value_type>& solution,
const std::vector<value_type>& matrix,
size_t dimension,
85 double svdThreshold,
int verbosity = 0);
91extern template void printMatrix<double>(
const std::vector<double>&,
size_t rows,
size_t cols, std::string title,
95 double threshold,
bool hermitian,
bool reduce_to_rank);
97extern template void eigenproblem<double>(std::vector<double>& eigenvectors, std::vector<double>& eigenvalues,
98 const std::vector<double>& matrix,
const std::vector<double>& metric,
99 const size_t dimension,
bool hermitian,
double svdThreshold,
int verbosity,
100 bool condone_complex);
103 const std::vector<double>& matrix,
const std::vector<double>& metric,
104 const std::vector<double>& rhs,
size_t dimension,
size_t nroot,
105 double augmented_hessian,
double svdThreshold,
int verbosity);
107extern template void solve_DIIS<double>(std::vector<double>& solution,
const std::vector<double>& matrix,
108 const size_t dimension,
double svdThreshold,
int verbosity);
113extern template void printMatrix<std::complex<double>>(
const std::vector<std::complex<double>>&,
size_t rows,
114 size_t cols, std::string title, std::ostream& s);
116extern template std::list<SVD<std::complex<double>>>
svd_system(
size_t nrows,
size_t ncols,
118 double threshold,
bool hermitian,
bool reduce_to_rank);
120extern template void eigenproblem<std::complex<double>>(std::vector<std::complex<double>>& eigenvectors,
121 std::vector<std::complex<double>>& eigenvalues,
122 const std::vector<std::complex<double>>& matrix,
123 const std::vector<std::complex<double>>& metric,
124 const size_t dimension,
bool hermitian,
double svdThreshold,
125 int verbosity,
bool condone_complex);
127extern template void solve_LinearEquations<std::complex<double>>(
128 std::vector<std::complex<double>>& solution, std::vector<std::complex<double>>& eigenvalues,
129 const std::vector<std::complex<double>>& matrix,
const std::vector<std::complex<double>>& metric,
130 const std::vector<std::complex<double>>& rhs,
size_t dimension,
size_t nroot,
double augmented_hessian,
131 double svdThreshold,
int verbosity);
133extern template void solve_DIIS<std::complex<double>>(std::vector<std::complex<double>>& solution,
134 const std::vector<std::complex<double>>& matrix,
135 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:11
template void printMatrix< double >(const std::vector< double > &, size_t rows, size_t cols, std::string title, std::ostream &s)
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, bool condone_complex)
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)
Definition: helper-implementation.h:143
std::list< SVD< value_type > > svd_system(size_t nrows, size_t ncols, const array::Span< value_type > &m, double 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
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
size_t get_rank(std::vector< value_type > eigenvalues, value_type 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)
void solve_DIIS(std::vector< value_type > &solution, const std::vector< value_type > &matrix, size_t dimension, double svdThreshold, int verbosity=0)
Definition: helper-implementation.h:560
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
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:310
Stores a singular value and corresponding left and right singular vectors.
Definition: helper.h:20
std::vector< value_type > v
right singular vector
Definition: helper.h:24
T value_type
Definition: helper.h:21
value_type value
Definition: helper.h:22
std::vector< value_type > u
left singular vector
Definition: helper.h:23