1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_ARRAYHANDLERDDISKSPARSE_H
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_ARRAYHANDLERDDISKSPARSE_H
4#include <molpro/Profiler.h>
5#include <molpro/linalg/array/ArrayHandler.h>
6#include <molpro/linalg/array/util/gemm.h>
13template <
typename AL,
typename AR,
bool = has_mapped_type_v<AR>>
19template <
typename AL,
typename AR>
28 AL
copy(
const AR &source)
override {
throw std::logic_error(
"General copy from sparse to dense is ill-defined"); };
29 void copy(AL &x,
const AR &y)
override {
static_assert(
true,
"General copy from sparse to dense is ill-defined"); };
31 void scal(
value_type alpha, AL &x)
override {
static_assert(
true,
"Use ArrayHandlerDistr for unary operations"); };
33 void fill(
value_type alpha, AL &x)
override {
static_assert(
true,
"Use ArrayHandlerDistr for unary operations"); };
47 gemm_outer_distr_sparse(alphas, xx, yy);
53 return gemm_inner_distr_sparse(xx, yy);
56 std::map<size_t, value_type_abs>
select_max_dot(
size_t n,
const AL &x,
const AR &y)
override {
57 return x.select_max_dot(n, y);
60 std::map<size_t, value_type_abs>
select(
size_t n,
const AL &x,
bool max =
false,
bool ignore_sign =
false)
override {
61 return x.select(n, max, ignore_sign);
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: ArrayHandlerDDiskSparse.h:60
ProxyHandle lazy_handle() override
Returns a lazy handle. Most implementations simply need to call the overload: return lazy_handle(*thi...
Definition: ArrayHandlerDDiskSparse.h:64
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: ArrayHandlerDDiskSparse.h:56
void scal(value_type alpha, AL &x) override
Definition: ArrayHandlerDDiskSparse.h:31
void copy(AL &x, const AR &y) override
Copy content of y into x.
Definition: ArrayHandlerDDiskSparse.h:29
void gemm_outer(const Matrix< value_type > alphas, const CVecRef< AR > &xx, const VecRef< AL > &yy) override
Definition: ArrayHandlerDDiskSparse.h:45
AL copy(const AR &source) override
Definition: ArrayHandlerDDiskSparse.h:28
void fill(value_type alpha, AL &x) override
Definition: ArrayHandlerDDiskSparse.h:33
value_type dot(const AL &x, const AR &y) override
Definition: ArrayHandlerDDiskSparse.h:40
Matrix< value_type > gemm_inner(const CVecRef< AL > &xx, const CVecRef< AR > &yy) override
Definition: ArrayHandlerDDiskSparse.h:50
void axpy(value_type alpha, const AR &x, AL &y) override
Definition: ArrayHandlerDDiskSparse.h:35
Definition: ArrayHandlerDDiskSparse.h:14
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
std::vector< std::weak_ptr< LazyHandle > > m_lazy_handles
keeps track of all created lazy handles
Definition: ArrayHandler.h:416
decltype(value_type_L{} *value_type_R{}) value_type
Definition: ArrayHandler.h:181
virtual ProxyHandle lazy_handle()=0
Returns a lazy handle. Most implementations simply need to call the overload: return lazy_handle(*thi...
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()
Matrix< typename array::mapped_or_value_type_t< AL > > gemm_inner_distr_sparse(const CVecRef< AL > &xx, const CVecRef< AR > &yy)
Definition: gemm.h:227
void gemm_outer_distr_sparse(const Matrix< typename array::mapped_or_value_type_t< AL > > alphas, const CVecRef< AR > &xx, const VecRef< AL > &yy)
Definition: gemm.h:208
Definition: ArrayHandler.h:22