1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_UTIL_H
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_UTIL_H
3#include <molpro/Profiler.h>
4#include <molpro/linalg/itsolv/ArrayHandlers.h>
5#include <molpro/linalg/itsolv/subspace/Matrix.h>
6#include <molpro/linalg/itsolv/wrap.h>
23 return std::sqrt(std::abs(handler.dot(x, x)));
34template <
typename value_type,
typename value_type_abs>
36 const size_t end,
const value_type_abs norm_thresh) {
37 for (
size_t i = start,
j = start;
i < end; ++
i) {
38 if (
norm[
j] < norm_thresh) {
50template <
class ForwardIt,
class EndIterator,
typename Int>
59template <
class R,
class Q>
61 auto q = handler.
copy(param);
81template <
class R,
class Q,
class P,
typename value_type>
88 prof->start(
"itsolv::util::construct_solutions");
89 assert(params.size() >= roots.size());
90 const auto nroots = roots.size();
95 auto coefficients = [&](
const std::vector<size_t>& indices) {
98 for (
size_t j = 0;
j < indices.size(); ++
j)
99 coeff(
j,
i) = solutions(roots[
i], indices[
j]);
103 for (
size_t j = 0;
j <
n; ++
j)
127template <
class Container>
129 std::sort(std::begin(indices), std::end(indices), std::greater<int>());
130 for (
auto i : indices)
131 params.erase(begin(params) +
i);
137 std::string
toupper(std::string
in)
const;
138 std::string
tolower(std::string
in)
const;
139 bool tobool(
const std::string&
in)
const;
144 const std::ctype<char>& facet = std::use_facet<std::ctype<char>>(std::locale());
153std::size_t
tosize(
const std::string&
key,
const std::string& value);
161 m_stream.flags(m_flags);
162 m_stream.precision(m_precision);
168 std::ostream& m_stream;
169 std::ios_base::fmtflags m_flags;
170 std::streamsize m_precision;
Enhances various operations between pairs of arrays and allows dynamic code injection with uniform in...
Definition ArrayHandler.h:163
virtual AL copy(const AR &source)=0
virtual void fill(value_type alpha, AL &x)=0
decltype(check_abs< value_type >()) value_type_abs
Definition ArrayHandler.h:183
Matrix container that allows simple data access, slicing, copying and resizing without loosing data.
Definition Matrix.h:32
Wraps some useful string manipulation functions.
Definition util.h:135
static std::map< std::string, std::string > parse_keyval_string(std::string s)
Definition util.cpp:54
bool tobool(const std::string &in) const
Definition util.cpp:19
std::string tolower(std::string in) const
Definition util.cpp:14
std::string toupper(std::string in) const
Definition util.cpp:9
static void crop_space(std::string &path)
Definition util.cpp:33
static std::shared_ptr< Profiler > single()
Definition ArrayHandlers.h:8
void remove_null_vectors(subspace::Matrix< value_type > &lin_trans, std::vector< value_type_abs > &norm, const size_t start, const size_t end, const value_type_abs norm_thresh)
Remove vectors considered null from the linear transformation matrix.
Definition util.h:35
Q construct_zeroed_copy(const R ¶m, array::ArrayHandler< Q, R > &handler)
Copy R parameter to Q and zero it. This ensures same size and distribution of the copy.
Definition util.h:60
bool is_iota(ForwardIt it_start, EndIterator it_end, Int value_start)
Returns true if iterator range contains integers starting with value_start and sequentially increment...
Definition util.h:51
void construct_solutions(const VecRef< R > ¶ms, 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
void delete_parameters(std::vector< int > indices, Container ¶ms)
Removes parameters.
Definition util.h:128
std::size_t tosize(const std::string &key, const std::string &value)
Converts the value of an option to a size.
Definition util.cpp:43
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
std::vector< std::reference_wrapper< const A > > CVecRef
Definition wrap.h:14
std::vector< std::reference_wrapper< A > > VecRef
Definition wrap.h:11