iterative-solver 0.0
ArrayHandlerDistrDDisk.h
1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_ARRAYHANDLERDISTRDDISK_H
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_ARRAYHANDLERDISTRDDISK_H
3
4#include <map>
5#include <molpro/linalg/array/ArrayHandler.h>
6#include <molpro/linalg/array/util/gemm.h>
7
10
11namespace molpro::linalg::array {
12
13template <class AL, class AR = AL>
14class ArrayHandlerDistrDDisk : public ArrayHandler<AL, AR> {
15public:
21
22 ProxyHandle lazy_handle() override { return this->lazy_handle(*this); };
23
24 using ArrayHandler<AL, AR>::lazy_handle;
25 using ArrayHandler<AL, AR>::error;
26
27 AL copy(const AR &source) override {
28 this->m_counter->copy++;
29 return AL{source};
30 };
31
32 void copy(AL &x, const AR &y) override {
33 this->m_counter->copy++;
34 x.copy(y);
35 };
36
37 void scal(value_type alpha, AL &x) override {
38 this->m_counter->scal++;
39 x.scal(alpha);
40 }
41
42 void fill(value_type alpha, AL &x) override { x.fill(alpha); }
43
44 void axpy(value_type alpha, const AR &x, AL &y) override {
45 this->m_counter->axpy++;
46 y.axpy(alpha, x);
47 }
48
49 value_type dot(const AL &x, const AR &y) override {
50 auto prof = molpro::Profiler::single()->push("ArrayHandlerDistrDDisk::dot");
51 this->m_counter->dot++;
52 return x.dot(y);
53 }
54
55 void gemm_outer(const Matrix<value_type> alphas, const CVecRef<AR> &xx, const VecRef<AL> &yy) override {
56 this->m_counter->gemm_outer++;
57 gemm_outer_distr_distr(alphas, xx, yy);
58 }
59
60 Matrix<value_type> gemm_inner(const CVecRef<AL> &xx, const CVecRef<AR> &yy) override {
61 this->m_counter->gemm_inner++;
62 return gemm_inner_distr_distr(xx, yy);
63 }
64
65 std::map<size_t, value_type_abs> select_max_dot(size_t n, const AL &x, const AR &y) override {
66 return x.select_max_dot(n, y);
67 }
68
69 std::map<size_t, value_type_abs> select(size_t n, const AL &x, bool max = false, bool ignore_sign = false) override {
70 return x.select(n, max, ignore_sign);
71 }
72};
73
74} // namespace molpro::linalg::array
75
76#endif // LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_ARRAYHANDLERDISTRDDISK_H
Definition: ArrayHandlerDistrDDisk.h:14
value_type dot(const AL &x, const AR &y) override
Definition: ArrayHandlerDistrDDisk.h:49
void gemm_outer(const Matrix< value_type > alphas, const CVecRef< AR > &xx, const VecRef< AL > &yy) override
Definition: ArrayHandlerDistrDDisk.h:55
Matrix< value_type > gemm_inner(const CVecRef< AL > &xx, const CVecRef< AR > &yy) override
Definition: ArrayHandlerDistrDDisk.h:60
void fill(value_type alpha, AL &x) override
Definition: ArrayHandlerDistrDDisk.h:42
AL copy(const AR &source) override
Definition: ArrayHandlerDistrDDisk.h:27
std::map< size_t, value_type_abs > select_max_dot(size_t n, const AL &x, const AR &y) override
Definition: ArrayHandlerDistrDDisk.h:65
void axpy(value_type alpha, const AR &x, AL &y) override
Definition: ArrayHandlerDistrDDisk.h:44
void scal(value_type alpha, AL &x) override
Definition: ArrayHandlerDistrDDisk.h:37
void copy(AL &x, const AR &y) override
Definition: ArrayHandlerDistrDDisk.h:32
std::map< size_t, value_type_abs > select(size_t n, const AL &x, bool max=false, bool ignore_sign=false) override
Select n indices with largest (or smallest) actual (or absolute) value.
Definition: ArrayHandlerDistrDDisk.h:69
ProxyHandle lazy_handle() override
Returns a lazy handle. Most implementations simply need to call the overload: return lazy_handle(*thi...
Definition: ArrayHandlerDistrDDisk.h:22
Enhances various operations between pairs of arrays and allows dynamic code injection with uniform in...
Definition: ArrayHandler.h:162
std::unique_ptr< Counter > m_counter
Definition: ArrayHandler.h:176
decltype(value_type_L{} *value_type_R{}) value_type
Definition: ArrayHandler.h:181
virtual void error(const std::string &message)
Throws an error.
Definition: ArrayHandler.h:268
Matrix container that allows simple data access, slicing, copying and resizing without loosing data.
Definition: Matrix.h:28
static std::shared_ptr< Profiler > single()
void gemm_outer_distr_distr(const Matrix< typename array::mapped_or_value_type_t< AL > > alphas, const CVecRef< DistrArrayFile > &xx, const VecRef< AL > &yy)
Definition: gemm.h:59
Matrix< typename array::mapped_or_value_type_t< AL > > gemm_inner_distr_distr(const CVecRef< AL > &yy, const CVecRef< DistrArrayFile > &xx)
Definition: gemm.h:32
Definition: ArrayHandler.h:22