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>
22 std::vector<value_type>
u;
23 std::vector<value_type>
v;
27 std::vector<double>& eigenvalues,
const size_t dimension);
34template <
typename value_type>
35size_t get_rank(std::vector<value_type> eigenvalues, value_type threshold);
37template <
typename value_type>
49template <
typename value_type,
typename std::enable_if_t<!is_complex<value_type>{}, std::
nullptr_t> =
nullptr>
51 bool hermitian =
false,
bool reduce_to_rank =
false);
52template <
typename value_type,
typename std::enable_if_t<is_complex<value_type>{},
int> = 0>
54 bool hermitian =
false,
bool reduce_to_rank =
false);
56template <
typename value_type>
57void printMatrix(
const std::vector<value_type>&,
size_t rows,
size_t cols, std::string title =
"",
58 std::ostream& s = molpro::cout);
60template <
typename value_type,
typename std::enable_if_t<is_complex<value_type>{},
int> = 0>
61void eigenproblem(std::vector<value_type>& eigenvectors, std::vector<value_type>& eigenvalues,
62 const std::vector<value_type>& matrix,
const std::vector<value_type>& metric,
size_t dimension,
63 bool hermitian,
double svdThreshold,
int verbosity,
bool condone_complex);
65template <
typename value_type,
typename std::enable_if_t<!is_complex<value_type>{}, std::
nullptr_t> =
nullptr>
66void eigenproblem(std::vector<value_type>& eigenvectors, std::vector<value_type>& eigenvalues,
67 const std::vector<value_type>& matrix,
const std::vector<value_type>& metric,
size_t dimension,
68 bool hermitian,
double svdThreshold,
int verbosity,
bool condone_complex);
70template <
typename value_type,
typename std::enable_if_t<is_complex<value_type>{},
int> = 0>
72 const std::vector<value_type>& matrix,
const std::vector<value_type>& metric,
73 const std::vector<value_type>& rhs,
size_t dimension,
size_t nroot,
double augmented_hessian,
74 double svdThreshold,
int verbosity);
76template <
typename value_type,
typename std::enable_if_t<!is_complex<value_type>{}, std::
nullptr_t> =
nullptr>
78 const std::vector<value_type>& matrix,
const std::vector<value_type>& metric,
79 const std::vector<value_type>& rhs,
size_t dimension,
size_t nroot,
double augmented_hessian,
80 double svdThreshold,
int verbosity);
82template <
typename value_type,
typename std::enable_if_t<is_complex<value_type>{},
int> = 0>
83void solve_DIIS(std::vector<value_type>& solution,
const std::vector<value_type>& matrix,
size_t dimension,
84 double svdThreshold,
int verbosity = 0);
85template <
typename value_type,
typename std::enable_if_t<!is_complex<value_type>{}, std::
nullptr_t> =
nullptr>
86void solve_DIIS(std::vector<value_type>& solution,
const std::vector<value_type>& matrix,
size_t dimension,
87 double svdThreshold,
int verbosity = 0);
93extern template void printMatrix<double>(
const std::vector<double>&,
size_t rows,
size_t cols, std::string title,
97 double threshold,
bool hermitian,
bool reduce_to_rank);
99extern template void eigenproblem<double>(std::vector<double>& eigenvectors, std::vector<double>& eigenvalues,
100 const std::vector<double>& matrix,
const std::vector<double>& metric,
101 const size_t dimension,
bool hermitian,
double svdThreshold,
int verbosity,
102 bool condone_complex);
104extern template void eigenproblem<double>(std::vector<double>& eigenvectors, std::vector<double>& eigenvalues,
105 const std::vector<double>& matrix,
const std::vector<double>& metric,
106 const size_t dimension,
bool hermitian,
double svdThreshold,
int verbosity,
107 bool condone_complex);
110 const std::vector<double>& matrix,
const std::vector<double>& metric,
111 const std::vector<double>& rhs,
size_t dimension,
size_t nroot,
112 double augmented_hessian,
double svdThreshold,
int verbosity);
115 const std::vector<double>& matrix,
const std::vector<double>& metric,
116 const std::vector<double>& rhs,
size_t dimension,
size_t nroot,
117 double augmented_hessian,
double svdThreshold,
int verbosity);
119extern template void solve_DIIS<double>(std::vector<double>& solution,
const std::vector<double>& matrix,
120 const size_t dimension,
double svdThreshold,
int verbosity);
125extern template void printMatrix<std::complex<double>>(
const std::vector<std::complex<double>>&,
size_t rows,
126 size_t cols, std::string title, std::ostream& s);
128extern template std::list<SVD<std::complex<double>>>
svd_system(
size_t nrows,
size_t ncols,
130 double threshold,
bool hermitian,
bool reduce_to_rank);
132extern template void eigenproblem<std::complex<double>>(std::vector<std::complex<double>>& eigenvectors,
133 std::vector<std::complex<double>>& eigenvalues,
134 const std::vector<std::complex<double>>& matrix,
135 const std::vector<std::complex<double>>& metric,
136 const size_t dimension,
bool hermitian,
double svdThreshold,
137 int verbosity,
bool condone_complex);
139extern template void eigenproblem<std::complex<double>>(std::vector<std::complex<double>>& eigenvectors,
140 std::vector<std::complex<double>>& eigenvalues,
141 const std::vector<std::complex<double>>& matrix,
142 const std::vector<std::complex<double>>& metric,
143 const size_t dimension,
bool hermitian,
double svdThreshold,
144 int verbosity,
bool condone_complex);
146extern template void solve_LinearEquations<std::complex<double>>(
147 std::vector<std::complex<double>>& solution, std::vector<std::complex<double>>& eigenvalues,
148 const std::vector<std::complex<double>>& matrix,
const std::vector<std::complex<double>>& metric,
149 const std::vector<std::complex<double>>& rhs,
size_t dimension,
size_t nroot,
double augmented_hessian,
150 double svdThreshold,
int verbosity);
152extern template void solve_LinearEquations<std::complex<double>>(
153 std::vector<std::complex<double>>& solution, std::vector<std::complex<double>>& eigenvalues,
154 const std::vector<std::complex<double>>& matrix,
const std::vector<std::complex<double>>& metric,
155 const std::vector<std::complex<double>>& rhs,
size_t dimension,
size_t nroot,
double augmented_hessian,
156 double svdThreshold,
int verbosity);
158extern template void solve_DIIS<std::complex<double>>(std::vector<std::complex<double>>& solution,
159 const std::vector<std::complex<double>>& matrix,
160 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:28
4-parameter interpolation of a 1-dimensional function given two points for which function values and ...
Definition: helper.h:10
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)
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:264
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:546
size_t get_rank(std::vector< value_type > eigenvalues, value_type threshold)
Definition: helper-implementation.h:222
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:620
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:312
int eigensolver_lapacke_dsyev(const std::vector< double > &matrix, std::vector< double > &eigenvectors, std::vector< double > &eigenvalues, const size_t dimension)
Definition: helper-implementation.h:122
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:306
Stores a singular value and corresponding left and right singular vectors.
Definition: helper.h:19
std::vector< value_type > v
right singular vector
Definition: helper.h:23
T value_type
Definition: helper.h:20
value_type value
Definition: helper.h:21
std::vector< value_type > u
left singular vector
Definition: helper.h:22