iterative-solver 0.0
molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle Class Reference

Registers operations for lazy evaluation. Evaluation is triggered by calling eval() or on destruction. More...

#include <ArrayHandler.h>

Collaboration diagram for molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle:

Detailed Description

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

Registers operations for lazy evaluation. Evaluation is triggered by calling eval() or on destruction.

Warning
The evaluation is performed by the handler, so it must be valid when eval() is called.

Public Types

using value_type = ArrayHandler< AL, AR >::value_type
 
template<typename T >
using ref_wrap = std::reference_wrapper< T >
 

Public Member Functions

 LazyHandle (ArrayHandler< AL, AR > &handler)
 
virtual ~LazyHandle ()
 
virtual void axpy (value_type alpha, const AR &x, AL &y)
 
virtual void dot (const AL &x, const AR &y, value_type &out)
 
virtual void eval ()
 Calls handler to evaluate the registered operations. More...
 
void invalidate ()
 Flag the handler as invalid so that no new operations are registered operations eval() does nothing. More...
 
bool invalid ()
 

Protected Member Functions

void error (std::string message)
 
virtual bool register_op_type (const std::string &type)
 Register an operation type. More...
 
void clear ()
 Clear the registry. More...
 

Protected Attributes

std::set< std::string > m_op_types
 Types of operations currently registered. Types are strings, because derived classes might add new operations. More...
 
util::OperationRegister< value_type, ref_wrap< const AR >, ref_wrap< AL > > m_axpy
 register of axpy operations More...
 
util::OperationRegister< ref_wrap< const AL >, ref_wrap< const AR >, ref_wrap< value_type > > m_dot
 register of dot operations More...
 
ArrayHandler< AL, AR > & m_handler
 all operations are still done through the handler More...
 
bool m_invalid = false
 flags if the handler has been destroyed and LazyHandle is now invalid More...
 

Member Typedef Documentation

◆ ref_wrap

template<class AL , class AR = AL>
template<typename T >
using molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::ref_wrap = std::reference_wrapper<T>

◆ value_type

template<class AL , class AR = AL>
using molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::value_type = ArrayHandler<AL, AR>::value_type

Constructor & Destructor Documentation

◆ LazyHandle()

template<class AL , class AR = AL>
molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::LazyHandle ( ArrayHandler< AL, AR > &  handler)
inlineexplicit

◆ ~LazyHandle()

template<class AL , class AR = AL>
virtual molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::~LazyHandle ( )
inlinevirtual

Member Function Documentation

◆ axpy()

template<class AL , class AR = AL>
virtual void molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::axpy ( value_type  alpha,
const AR &  x,
AL &  y 
)
inlinevirtual

◆ clear()

template<class AL , class AR = AL>
void molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::clear ( )
inlineprotected

Clear the registry.

◆ dot()

template<class AL , class AR = AL>
virtual void molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::dot ( const AL &  x,
const AR &  y,
value_type out 
)
inlinevirtual

◆ error()

template<class AL , class AR = AL>
void molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::error ( std::string  message)
inlineprotected

◆ eval()

template<class AL , class AR = AL>
virtual void molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::eval ( )
inlinevirtual

Calls handler to evaluate the registered operations.

◆ invalid()

template<class AL , class AR = AL>
bool molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::invalid ( )
inline

Returns true if the handle is marked as invalid. LazyHandle becomes invalid when the overlying ArrayHandler is destroyed, or invalidate() is called

◆ invalidate()

template<class AL , class AR = AL>
void molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::invalidate ( )
inline

Flag the handler as invalid so that no new operations are registered operations eval() does nothing.

◆ register_op_type()

template<class AL , class AR = AL>
virtual bool molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::register_op_type ( const std::string &  type)
inlineprotectedvirtual

Register an operation type.

Currently, only one type of operation is suported at any time.

Parameters
typetype of operation
Returns
true if that operation type is currently allowed, false otherwise

Member Data Documentation

◆ m_axpy

template<class AL , class AR = AL>
util::OperationRegister<value_type, ref_wrap<const AR>, ref_wrap<AL> > molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::m_axpy
protected

register of axpy operations

◆ m_dot

template<class AL , class AR = AL>
util::OperationRegister<ref_wrap<const AL>, ref_wrap<const AR>, ref_wrap<value_type> > molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::m_dot
protected

register of dot operations

◆ m_handler

template<class AL , class AR = AL>
ArrayHandler<AL, AR>& molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::m_handler
protected

all operations are still done through the handler

◆ m_invalid

template<class AL , class AR = AL>
bool molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::m_invalid = false
protected

flags if the handler has been destroyed and LazyHandle is now invalid

◆ m_op_types

template<class AL , class AR = AL>
std::set<std::string> molpro::linalg::array::ArrayHandler< AL, AR >::LazyHandle::m_op_types
protected

Types of operations currently registered. Types are strings, because derived classes might add new operations.