1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_ARRAYHANDLERDDISKITERABLE_H
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_ARRAYHANDLERDDISKITERABLE_H
3#include <molpro/linalg/array/ArrayHandlerIterableDDisk.h>
4#include <molpro/linalg/array/ArrayHandlerWithCopyFunc.h>
5#include <molpro/linalg/array/util/gemm.h>
23template <
class AL,
class AR>
31 static_assert(is_contiguous_v<AR>,
"ArrayHandlerDDiskIterable: the right array must be contiguous");
32 static_assert(std::is_same_v<value_type, typename AL::value_type>,
33 "ArrayHandlerDDiskIterable: the arrays must have the same value type");
56 void copy(AL &x,
const AR &y)
override {
88 std::map<size_t, value_type_abs>
select_max_dot(
size_t n,
const AL &x,
const AR &y)
override {
92 std::map<size_t, value_type>
select(
size_t n,
const AL &x,
bool max =
false,
bool ignore_sign =
false)
override {
93 return x.select(n, max, ignore_sign);
103 static MPI_Comm comm_self() {
104 const auto comm = molpro::mpi::comm_self();
106 if (comm == MPI_COMM_NULL)
107 throw std::logic_error(
"ArrayHandlerDDiskIterable: MPI must be initialised before a distributed array is "
108 "created as a copy of a contiguous one");
Array handler between a distributed array (left), typically one held on disk, and a contiguous array ...
Definition ArrayHandlerDDiskIterable.h:24
void scal(value_type alpha, AL &x) override
Definition ArrayHandlerDDiskIterable.h:61
value_type dot(const AL &x, const AR &y) override
The hermitian inner product <x|y>: conjugate-linear in x, linear in y.
Definition ArrayHandlerDDiskIterable.h:73
Matrix< value_type > gemm_inner(const CVecRef< AL > &xx, const CVecRef< AR > &yy) override
Definition ArrayHandlerDDiskIterable.h:83
ArrayHandlerDDiskIterable()
New arrays are created by AL::CreateTempCopy() on molpro::mpi::comm_self(), with any file in its defa...
Definition ArrayHandlerDDiskIterable.h:36
ProxyHandle lazy_handle() override
Returns a lazy handle. Most implementations simply need to call the overload: return lazy_handle(*thi...
Definition ArrayHandlerDDiskIterable.h:50
std::map< size_t, value_type > 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 ArrayHandlerDDiskIterable.h:92
ArrayHandlerDDiskIterable(const std::string &directory)
New arrays are created by AL::CreateTempCopy() on molpro::mpi::comm_self(), with any file in director...
Definition ArrayHandlerDDiskIterable.h:41
ArrayHandlerDDiskIterable(std::function< AL(const AR &)> copy_func)
Constructor taking a copy function, which returns a new distributed array as a copy of a contiguous o...
Definition ArrayHandlerDDiskIterable.h:47
void fill(value_type alpha, AL &x) override
Definition ArrayHandlerDDiskIterable.h:66
void axpy(value_type alpha, const AR &x, AL &y) override
Definition ArrayHandlerDDiskIterable.h:68
void copy(AL &x, const AR &y) override
Copy content of y into x.
Definition ArrayHandlerDDiskIterable.h:56
std::map< size_t, value_type_abs > select_max_dot(size_t n, const AL &x, const AR &y) override
Select n indices with largest by absolute value contributions to the dot product.
Definition ArrayHandlerDDiskIterable.h:88
void gemm_outer(const Matrix< value_type > alphas, const CVecRef< AR > &xx, const VecRef< AL > &yy) override
Definition ArrayHandlerDDiskIterable.h:78
Base for handlers whose left arrays are created by a function given by the user.
Definition ArrayHandlerWithCopyFunc.h:16
A convenience wrapper around a pointer to the LazyHandle.
Definition ArrayHandler.h:392
Enhances various operations between pairs of arrays and allows dynamic code injection with uniform in...
Definition ArrayHandler.h:163
std::unique_ptr< Counter > m_counter
Definition ArrayHandler.h:177
typename array::mapped_or_value_type_t< AR > value_type_R
Definition ArrayHandler.h:181
typename array::mapped_or_value_type_t< AL > value_type_L
Definition ArrayHandler.h:180
decltype(value_type_L{} *value_type_R{}) value_type
Definition ArrayHandler.h:182
decltype(check_abs< value_type >()) value_type_abs
Definition ArrayHandler.h:183
virtual void error(const std::string &message)
Throws an error.
Definition ArrayHandler.h:276
Matrix container that allows simple data access, slicing, copying and resizing without loosing data.
Definition Matrix.h:32
auto contiguous_span(R &r)
A view of all the elements of a contiguous array.
Definition util.h:93
void gemm_outer_contiguous_distr(const Matrix< typename AD::value_type > &alphas, const CVecRef< R > &rr, const VecRef< AD > &qq)
qq += alphas^T rr for contiguous arrays rr and distributed arrays qq. Local.
Definition gemm.h:410
Matrix< typename AD::value_type > gemm_inner_distr_contiguous(const CVecRef< AD > &qq, const CVecRef< R > &rr)
The overlap matrix (qq.size(), rr.size()) between distributed arrays qq and contiguous arrays rr....
Definition gemm.h:383
Definition ArrayHandler.h:19