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>
22template <
typename value_type,
typename value_type_abs>
24 const size_t end,
const value_type_abs norm_thresh) {
25 for (
size_t i = start, j = start; i < end; ++i) {
26 if (norm[j] < norm_thresh) {
27 norm.erase(begin(norm) + j);
38template <
class ForwardIt,
class EndIterator,
typename Int>
39bool is_iota(ForwardIt it_start, EndIterator it_end, Int value_start) {
41 for (
auto it = it_start; it != it_end && result; ++it, ++value_start)
42 result = (*it) == value_start;
47template <
class R,
class Q>
49 auto q = handler.
copy(param);
69template <
class R,
class Q,
class P>
76 prof->start(
"itsolv::util::construct_solutions");
77 assert(params.size() >= roots.size());
78 for (
size_t i = 0; i < roots.size(); ++i)
79 handler_rr.
fill(0, params.at(i));
80 for (
size_t i = 0; i < roots.size(); ++i) {
82 for (
size_t j = 0; j < pparams.size(); ++j)
83 handler_rp.
axpy(solutions(root, oP + j), pparams.at(j), params.at(i));
84 for (
size_t j = 0; j < qparams.size(); ++j)
85 handler_rq.
axpy(solutions(root, oQ + j), qparams.at(j), params.at(i));
86 for (
size_t j = 0; j < dparams.size(); ++j)
87 handler_rq.
axpy(solutions(root, oD + j), dparams.at(j), params.at(i));
97template <
class Container>
99 std::sort(std::begin(indices), std::end(indices), std::greater<int>());
100 for (
auto i : indices)
101 params.erase(begin(params) + i);
107 std::string
toupper(std::string in)
const;
108 std::string
tolower(std::string in)
const;
109 bool tobool(
const std::string& in)
const;
114 const std::ctype<char>& facet = std::use_facet<std::ctype<char>>(std::locale());
Enhances various operations between pairs of arrays and allows dynamic code injection with uniform in...
Definition: ArrayHandler.h:162
virtual AL copy(const AR &source)=0
virtual void axpy(value_type alpha, const AR &x, AL &y)=0
virtual void fill(value_type alpha, AL &x)=0
void remove_row(index_type row)
removes a row from the matrix
Definition: Matrix.h:142
Wraps some useful string manipulation functions.
Definition: util.h:105
static std::map< std::string, std::string > parse_keyval_string(std::string s)
Definition: util.cpp:38
bool tobool(const std::string &in) const
Definition: util.cpp:14
std::string tolower(std::string in) const
Definition: util.cpp:9
std::string toupper(std::string in) const
Definition: util.cpp:4
static void crop_space(std::string &path)
Definition: util.cpp:28
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:23
void construct_solutions(const VecRef< R > ¶ms, const std::vector< int > &roots, const subspace::Matrix< double > &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:70
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:48
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:39
void delete_parameters(std::vector< int > indices, Container ¶ms)
Removes parameters.
Definition: util.h:98
std::vector< std::reference_wrapper< const A > > CVecRef
Definition: wrap.h:14
std::vector< std::reference_wrapper< A > > VecRef
Definition: wrap.h:11