iterative-solver 0.0
molpro::linalg::array::ArrayHandlerDefault< AL, AR > Class Template Reference

Fall back handler that calls member functions of arrays. More...

#include <ArrayHandlerDefault.h>

Inheritance diagram for molpro::linalg::array::ArrayHandlerDefault< AL, AR >:
Collaboration diagram for molpro::linalg::array::ArrayHandlerDefault< AL, AR >:

Detailed Description

template<class AL, class AR = AL>
class molpro::linalg::array::ArrayHandlerDefault< AL, AR >

Fall back handler that calls member functions of arrays.

Public Member Functions

AL copy (const AR &source) override
 
void copy (AL &x, const AR &y) override
 
void scal (value_type alpha, AL &x) override
 
void fill (value_type alpha, AL &x) override
 
void axpy (value_type alpha, const AR &x, AL &y) override
 
value_type dot (const AL &x, const AR &y) override
 
void gemm_outer (const Matrix< value_type > alphas, const CVecRef< AR > &xx, const VecRef< AL > &yy) override
 
Matrix< value_typegemm_inner (const CVecRef< AL > &xx, const CVecRef< AR > &yy) override
 
std::map< size_t, value_type_absselect_max_dot (size_t n, const AL &x, const AR &y) override
 
std::map< size_t, value_type_absselect (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. More...
 
ProxyHandle lazy_handle () override
 Returns a lazy handle. Most implementations simply need to call the overload: return lazy_handle(*this);. More...
 
- Public Member Functions inherited from molpro::linalg::array::ArrayHandler< AL, AL >
virtual AL copy (const AL &source)=0
 
virtual void copy (AL &x, const AL &y)=0
 Copy content of y into x. More...
 
virtual void scal (value_type alpha, AL &x)=0
 
virtual void fill (value_type alpha, AL &x)=0
 
virtual void axpy (value_type alpha, const AL &x, AL &y)=0
 
virtual value_type dot (const AL &x, const AL &y)=0
 
virtual void gemm_outer (const Matrix< value_type > alphas, const CVecRef< AL > &xx, const VecRef< AL > &yy)=0
 
virtual Matrix< value_typegemm_inner (const CVecRef< AL > &xx, const CVecRef< AL > &yy)=0
 
virtual std::map< size_t, value_type_absselect_max_dot (size_t n, const AL &x, const AL &y)=0
 Select n indices with largest by absolute value contributions to the dot product. More...
 
virtual std::map< size_t, value_typeselect (size_t n, const AL &x, bool max=false, bool ignore_sign=false)=0
 Select n indices with largest (or smallest) actual (or absolute) value. More...
 
const Counter & counter () const
 
std::string counter_to_string (std::string L, std::string R)
 
void clear_counter ()
 
virtual ~ArrayHandler ()
 Destroys ArrayHandler instance and invalidates any LazyHandler it created. Invalidated handler will not evaluate. More...
 
virtual ProxyHandle lazy_handle ()=0
 Returns a lazy handle. Most implementations simply need to call the overload: return lazy_handle(*this);. More...
 

Additional Inherited Members

- Public Types inherited from molpro::linalg::array::ArrayHandler< AL, AL >
using value_type_L = typename array::mapped_or_value_type_t< AL >
 
using value_type_R = typename array::mapped_or_value_type_t< AL >
 
using value_type = decltype(value_type_L{} *value_type_R{})
 
using value_type_abs = decltype(check_abs< value_type >())
 
- Protected Member Functions inherited from molpro::linalg::array::ArrayHandler< AL, AL >
 ArrayHandler ()
 
 ArrayHandler (const ArrayHandler &)=default
 
virtual void error (const std::string &message)
 Throws an error. More...
 
virtual void fused_axpy (const std::vector< std::tuple< size_t, size_t, size_t > > &reg, const std::vector< value_type > &alphas, const std::vector< std::reference_wrapper< const AL > > &xx, std::vector< std::reference_wrapper< AL > > &yy)
 Default implementation of fused_axpy without any simplification. More...
 
virtual void fused_dot (const std::vector< std::tuple< size_t, size_t, size_t > > &reg, const std::vector< std::reference_wrapper< const AL > > &xx, const std::vector< std::reference_wrapper< const AL > > &yy, std::vector< std::reference_wrapper< value_type > > &out)
 Default implementation of fused_dot without any simplification. More...
 
void save_handle (const std::shared_ptr< LazyHandle > &handle)
 Save weak ptr to a lazy handle. More...
 
ProxyHandle lazy_handle (ArrayHandler< AL, AL > &handler)
 
- Protected Attributes inherited from molpro::linalg::array::ArrayHandler< AL, AL >
std::unique_ptr< Counter > m_counter
 
std::vector< std::weak_ptr< LazyHandle > > m_lazy_handles
 keeps track of all created lazy handles More...
 

Member Function Documentation

◆ axpy()

template<class AL , class AR = AL>
void molpro::linalg::array::ArrayHandlerDefault< AL, AR >::axpy ( value_type  alpha,
const AR &  x,
AL &  y 
)
inlineoverride

◆ copy() [1/2]

template<class AL , class AR = AL>
void molpro::linalg::array::ArrayHandlerDefault< AL, AR >::copy ( AL &  x,
const AR &  y 
)
inlineoverride

◆ copy() [2/2]

template<class AL , class AR = AL>
AL molpro::linalg::array::ArrayHandlerDefault< AL, AR >::copy ( const AR &  source)
inlineoverride

◆ dot()

template<class AL , class AR = AL>
value_type molpro::linalg::array::ArrayHandlerDefault< AL, AR >::dot ( const AL &  x,
const AR &  y 
)
inlineoverride

◆ fill()

template<class AL , class AR = AL>
void molpro::linalg::array::ArrayHandlerDefault< AL, AR >::fill ( value_type  alpha,
AL &  x 
)
inlineoverridevirtual

◆ gemm_inner()

template<class AL , class AR = AL>
Matrix< value_type > molpro::linalg::array::ArrayHandlerDefault< AL, AR >::gemm_inner ( const CVecRef< AL > &  xx,
const CVecRef< AR > &  yy 
)
inlineoverride

◆ gemm_outer()

template<class AL , class AR = AL>
void molpro::linalg::array::ArrayHandlerDefault< AL, AR >::gemm_outer ( const Matrix< value_type alphas,
const CVecRef< AR > &  xx,
const VecRef< AL > &  yy 
)
inlineoverride

◆ lazy_handle()

template<class AL , class AR = AL>
ProxyHandle molpro::linalg::array::ArrayHandlerDefault< AL, AR >::lazy_handle ( )
inlineoverridevirtual

Returns a lazy handle. Most implementations simply need to call the overload: return lazy_handle(*this);.

Implements molpro::linalg::array::ArrayHandler< AL, AL >.

◆ scal()

template<class AL , class AR = AL>
void molpro::linalg::array::ArrayHandlerDefault< AL, AR >::scal ( value_type  alpha,
AL &  x 
)
inlineoverridevirtual

◆ select()

template<class AL , class AR = AL>
std::map< size_t, value_type_abs > molpro::linalg::array::ArrayHandlerDefault< AL, AR >::select ( size_t  n,
const AL &  x,
bool  max = false,
bool  ignore_sign = false 
)
inlineoverridevirtual

Select n indices with largest (or smallest) actual (or absolute) value.

Parameters
nnumber of indices to select
xarray to examine
maxIf true, select largest values, otherwise smallest
ignore_signIf true, consider std::abs() of elements
Returns
map of indices and corresponding values

Implements molpro::linalg::array::ArrayHandler< AL, AL >.

◆ select_max_dot()

template<class AL , class AR = AL>
std::map< size_t, value_type_abs > molpro::linalg::array::ArrayHandlerDefault< AL, AR >::select_max_dot ( size_t  n,
const AL &  x,
const AR &  y 
)
inlineoverride