iterative-solver 0.0
molpro::linalg::array::util::Distribution< Ind > Class Template Reference

Specifies distribution of a contiguous array into non-overlapping chunks. More...

#include <Distribution.h>

Detailed Description

template<typename Ind = size_t>
class molpro::linalg::array::util::Distribution< Ind >

Specifies distribution of a contiguous array into non-overlapping chunks.

Template Parameters
Ind
Examples
LinearEigensystemDistrArrayExample.cpp, and OptimizeDistrArrayExample.cpp.

Public Types

using index_type = Ind
 

Public Member Functions

 Distribution ()=default
 
 Distribution (const Distribution< Ind > &)=default
 
 Distribution (Distribution< Ind > &&) noexcept=default
 
Distribution< Ind > & operator= (const Distribution< Ind > &)=default
 
Distribution< Ind > & operator= (Distribution< Ind > &&) noexcept=default
 
 ~Distribution ()=default
 
 Distribution (const std::vector< index_type > &indices)
 Construct a contiguous distribution list using vector of start indices. More...
 
std::pair< int, int > cover (index_type lo, index_type hi) const
 Maps first and last index in the array to a pair of chunks encapsulating the corresponding range. More...
 
int cover (index_type ind) const
 
std::pair< index_type, index_typerange (int chunk) const
 Returns [fist, end) indices for section of array assigned to chunk. More...
 
std::pair< index_type, index_typeborder () const
 
size_t size () const
 Number of chunks in the distribution. More...
 
const std::vector< index_type > & chunk_borders () const
 
bool compatible (const Distribution< Ind > &other) const
 Checks that other distribution is the same. More...
 

Protected Attributes

std::vector< index_typem_chunk_borders
 list of starting indices for each chunk with past the end index as last element. e.g. {|0,1,2,3|,4,5|,6,7,8|9} -> {0,4,6,9,10} More...
 

Friends

void swap (Distribution< index_type > &l, Distribution< index_type > &r)
 

Member Typedef Documentation

◆ index_type

template<typename Ind = size_t>
using molpro::linalg::array::util::Distribution< Ind >::index_type = Ind

Constructor & Destructor Documentation

◆ Distribution() [1/4]

template<typename Ind = size_t>
molpro::linalg::array::util::Distribution< Ind >::Distribution ( )
default

◆ Distribution() [2/4]

template<typename Ind = size_t>
molpro::linalg::array::util::Distribution< Ind >::Distribution ( const Distribution< Ind > &  )
default

◆ Distribution() [3/4]

template<typename Ind = size_t>
molpro::linalg::array::util::Distribution< Ind >::Distribution ( Distribution< Ind > &&  )
defaultnoexcept

◆ ~Distribution()

template<typename Ind = size_t>
molpro::linalg::array::util::Distribution< Ind >::~Distribution ( )
default

◆ Distribution() [4/4]

template<typename Ind = size_t>
molpro::linalg::array::util::Distribution< Ind >::Distribution ( const std::vector< index_type > &  indices)
inline

Construct a contiguous distribution list using vector of start indices.

Parameters
indiceslist of starting indices for each chunk with last element storing past the end index

Member Function Documentation

◆ border()

template<typename Ind = size_t>
std::pair< index_type, index_type > molpro::linalg::array::util::Distribution< Ind >::border ( ) const
inline
Returns
[start, end) indices of the distribution

◆ chunk_borders()

template<typename Ind = size_t>
const std::vector< index_type > & molpro::linalg::array::util::Distribution< Ind >::chunk_borders ( ) const
inline

◆ compatible()

template<typename Ind = size_t>
bool molpro::linalg::array::util::Distribution< Ind >::compatible ( const Distribution< Ind > &  other) const
inline

Checks that other distribution is the same.

◆ cover() [1/2]

template<typename Ind = size_t>
int molpro::linalg::array::util::Distribution< Ind >::cover ( index_type  ind) const
inline
Returns
index of chunk containing ind if it is within border or size() otherwise.
Parameters
indarray index

◆ cover() [2/2]

template<typename Ind = size_t>
std::pair< int, int > molpro::linalg::array::util::Distribution< Ind >::cover ( index_type  lo,
index_type  hi 
) const
inline

Maps first and last index in the array to a pair of chunks encapsulating the corresponding range.

Parameters
lofirst index of range
hipast-the-end index of range
Returns
pair of first and last chunk indices encapsulating this range, or size() if range is outside of border()

◆ operator=() [1/2]

template<typename Ind = size_t>
Distribution< Ind > & molpro::linalg::array::util::Distribution< Ind >::operator= ( const Distribution< Ind > &  )
default

◆ operator=() [2/2]

template<typename Ind = size_t>
Distribution< Ind > & molpro::linalg::array::util::Distribution< Ind >::operator= ( Distribution< Ind > &&  )
defaultnoexcept

◆ range()

template<typename Ind = size_t>
std::pair< index_type, index_type > molpro::linalg::array::util::Distribution< Ind >::range ( int  chunk) const
inline

Returns [fist, end) indices for section of array assigned to chunk.

◆ size()

template<typename Ind = size_t>
size_t molpro::linalg::array::util::Distribution< Ind >::size ( ) const
inline

Number of chunks in the distribution.

Friends And Related Function Documentation

◆ swap

template<typename Ind = size_t>
void swap ( Distribution< index_type > &  l,
Distribution< index_type > &  r 
)
friend

Member Data Documentation

◆ m_chunk_borders

template<typename Ind = size_t>
std::vector<index_type> molpro::linalg::array::util::Distribution< Ind >::m_chunk_borders
protected

list of starting indices for each chunk with past the end index as last element. e.g. {|0,1,2,3|,4,5|,6,7,8|9} -> {0,4,6,9,10}