iterative-solver 0.0
molpro::linalg::array::util Namespace Reference

Classes

struct  ArrayHandlerError
 
class  BufferManager
 BufferManager provides single-buffered or asynchronous double-buffered read access to the data in a collection of DistrArray objects. At construction, an amount of memory is allocated as a buffer, and the buffer is divided into one or more chunks that are independent windows on the data. Sequential access to the data is provided through iterators. More...
 
struct  CompareAbs
 
class  DistrFlags
 Distributed array of integer flags with one flag per process and a locking mechanism to ensure atomic access. More...
 
class  Distribution
 Specifies distribution of a contiguous array into non-overlapping chunks. More...
 
struct  is_std_array
 
struct  is_std_array< std::array< T, N > >
 
class  LockMPI3
 Atomic lock allowing only one process to acquire it. Implemented using MPI3 RMA. More...
 
struct  OperationRegister
 
struct  RefEqual
 When called returns true if addresses of two references are the same. More...
 
class  ScopeLock
 Utility object that locks on creation and unlocks on destruction. More...
 
class  Task
 
struct  TempHandle
 Static registrar of temporary handles. More...
 

Enumerations

enum  gemm_type {
  inner ,
  outer
}
 

Functions

template<typename X , typename Y , typename Z , class EqualX , class EqualY , class EqualZ >
std::tuple< std::vector< std::tuple< size_t, size_t, size_t > >, std::vector< X >, std::vector< Y >, std::vector< Z > > remove_duplicates (const std::list< std::tuple< X, Y, Z > > &reg, EqualX equal_x, EqualY equal_y, EqualZ equal_z)
 Find duplicates references to x and y arrays and store unique elements in a separate vector. More...
 
template<class Compare >
std::list< std::pair< DistrArray::index_type, DistrArray::value_type > > extrema (const DistrArray &x, int n)
 
std::map< size_t, double > select_max_dot_broadcast (size_t n, std::map< size_t, double > &local_selection, MPI_Comm communicator)
 
template<typename Ind >
Distribution< Ind > make_distribution_spread_remainder (size_t dimension, int n_chunks)
 Creates a distribution with first (dimension % n_chunks) chunks larger by 1 element. More...
 
template<class X , typename value_type , typename std::enable_if< std::is_compound< value_type >::value, value_type >::type * = nullptr>
auto select (size_t n, const X &x, bool max=false, bool ignore_sign=false)
 Select n indices with largest (or smallest) actual (or absolute) value. More...
 
template<class X , typename value_type >
auto select_sparse (size_t n, const X &x, bool max=false, bool ignore_sign=false)
 Select n indices with largest (or smallest) actual (or absolute) value. More...
 
template<class X , class Y , typename value_type , typename value_type_abs >
auto select_max_dot (size_t n, const X &x, const Y &y)
 Select n indices with largest by absolute value contributions to the dot product. More...
 
template<class X , class Y , typename value_type , typename value_type_abs >
auto select_max_dot_iter_sparse (size_t n, const X &x, const Y &y)
 Select n indices with largest by absolute value contributions to the dot product. More...
 
template<class X , class Y , typename value_type , typename value_type_abs >
auto select_max_dot_sparse (size_t n, const X &x, const Y &y)
 Select n indices with largest by absolute value contributions to the dot product. More...
 
fs::path temp_file_name (const fs::path &base_name, const std::string &suffix)
 Returns random file name for a temporary file. More...
 
template<class AL >
Matrix< typename array::mapped_or_value_type_t< AL > > gemm_inner_distr_distr (const CVecRef< AL > &yy, const CVecRef< DistrArrayFile > &xx)
 
template<class AL , typename = std::enable_if_t<!std::is_same_v<std::decay_t<AL>, DistrArrayFile>>>
Matrix< typename array::mapped_or_value_type_t< AL > > gemm_inner_distr_distr (const CVecRef< DistrArrayFile > &xx, const CVecRef< AL > &yy)
 
template<class AL >
void gemm_outer_distr_distr (const Matrix< typename array::mapped_or_value_type_t< AL > > alphas, const CVecRef< DistrArrayFile > &xx, const VecRef< AL > &yy)
 
template<class AL >
void gemm_distr_distr (array::mapped_or_value_type_t< AL > *alphadata, const CVecRef< DistrArrayFile > &xx, const VecRef< AL > &yy, gemm_type gemm_type)
 
template<class AL , class AR = AL>
Matrix< typename array::mapped_or_value_type_t< AL > > gemm_inner_distr_distr (const CVecRef< AL > &xx, const CVecRef< AR > &yy)
 
template<class AL , class AR = AL>
void gemm_outer_distr_distr (const Matrix< typename array::mapped_or_value_type_t< AL > > alphas, const CVecRef< AR > &xx, const VecRef< AL > &yy)
 
template<class AL , class AR = AL>
void gemm_outer_distr_sparse (const Matrix< typename array::mapped_or_value_type_t< AL > > alphas, const CVecRef< AR > &xx, const VecRef< AL > &yy)
 
template<class AL , class AR = AL>
Matrix< typename array::mapped_or_value_type_t< AL > > gemm_inner_distr_sparse (const CVecRef< AL > &xx, const CVecRef< AR > &yy)
 
template<class Handler , class AL , class AR = AL>
void gemm_outer_default (Handler &handler, const Matrix< typename Handler::value_type > alphas, const CVecRef< AR > &xx, const VecRef< AL > &yy)
 
template<class Handler , class AL , class AR = AL>
Matrix< typename Handler::value_type > gemm_inner_default (Handler &handler, const CVecRef< AL > &xx, const CVecRef< AR > &yy)
 
void gather_all (const Distribution< size_t > &distr, MPI_Comm commun, double *first_elem)
 Replicate data of a full container on all the processes based on distributed pieces. More...
 
void swap (DistrFlags &x, DistrFlags &y)
 

Variables

template<typename T >
constexpr bool is_std_array_v = is_std_array<T>::value
 
template<typename T >
constexpr bool is_array_v = std::is_array<T>::value || is_std_array_v<T>
 
int s_temp_file_name_count = 0
 
std::mutex s_mutex
 

Enumeration Type Documentation

◆ gemm_type

Enumerator
inner 
outer 

Function Documentation

◆ extrema()

template<class Compare >
std::list< std::pair< DistrArray::index_type, DistrArray::value_type > > molpro::linalg::array::util::extrema ( const DistrArray x,
int  n 
)

◆ gather_all()

void molpro::linalg::array::util::gather_all ( const Distribution< size_t > &  distr,
MPI_Comm  commun,
double *  first_elem 
)

Replicate data of a full container on all the processes based on distributed pieces.

Parameters
distrdistribution of the container, which local data chuncks are to be replicated
communMPI communicator
first_elempointer to the beginning of the container, which data to be replicated

◆ gemm_distr_distr()

template<class AL >
void molpro::linalg::array::util::gemm_distr_distr ( array::mapped_or_value_type_t< AL > *  alphadata,
const CVecRef< DistrArrayFile > &  xx,
const VecRef< AL > &  yy,
gemm_type  gemm_type 
)

◆ gemm_inner_default()

template<class Handler , class AL , class AR = AL>
Matrix< typename Handler::value_type > molpro::linalg::array::util::gemm_inner_default ( Handler &  handler,
const CVecRef< AL > &  xx,
const CVecRef< AR > &  yy 
)

◆ gemm_inner_distr_distr() [1/3]

template<class AL , class AR = AL>
Matrix< typename array::mapped_or_value_type_t< AL > > molpro::linalg::array::util::gemm_inner_distr_distr ( const CVecRef< AL > &  xx,
const CVecRef< AR > &  yy 
)

◆ gemm_inner_distr_distr() [2/3]

template<class AL >
Matrix< typename array::mapped_or_value_type_t< AL > > molpro::linalg::array::util::gemm_inner_distr_distr ( const CVecRef< AL > &  yy,
const CVecRef< DistrArrayFile > &  xx 
)

◆ gemm_inner_distr_distr() [3/3]

template<class AL , typename = std::enable_if_t<!std::is_same_v<std::decay_t<AL>, DistrArrayFile>>>
Matrix< typename array::mapped_or_value_type_t< AL > > molpro::linalg::array::util::gemm_inner_distr_distr ( const CVecRef< DistrArrayFile > &  xx,
const CVecRef< AL > &  yy 
)

◆ gemm_inner_distr_sparse()

template<class AL , class AR = AL>
Matrix< typename array::mapped_or_value_type_t< AL > > molpro::linalg::array::util::gemm_inner_distr_sparse ( const CVecRef< AL > &  xx,
const CVecRef< AR > &  yy 
)

◆ gemm_outer_default()

template<class Handler , class AL , class AR = AL>
void molpro::linalg::array::util::gemm_outer_default ( Handler &  handler,
const Matrix< typename Handler::value_type >  alphas,
const CVecRef< AR > &  xx,
const VecRef< AL > &  yy 
)

◆ gemm_outer_distr_distr() [1/2]

template<class AL , class AR = AL>
void molpro::linalg::array::util::gemm_outer_distr_distr ( const Matrix< typename array::mapped_or_value_type_t< AL > >  alphas,
const CVecRef< AR > &  xx,
const VecRef< AL > &  yy 
)

◆ gemm_outer_distr_distr() [2/2]

template<class AL >
void molpro::linalg::array::util::gemm_outer_distr_distr ( const Matrix< typename array::mapped_or_value_type_t< AL > >  alphas,
const CVecRef< DistrArrayFile > &  xx,
const VecRef< AL > &  yy 
)

◆ gemm_outer_distr_sparse()

template<class AL , class AR = AL>
void molpro::linalg::array::util::gemm_outer_distr_sparse ( const Matrix< typename array::mapped_or_value_type_t< AL > >  alphas,
const CVecRef< AR > &  xx,
const VecRef< AL > &  yy 
)

◆ make_distribution_spread_remainder()

template<typename Ind >
Distribution< Ind > molpro::linalg::array::util::make_distribution_spread_remainder ( size_t  dimension,
int  n_chunks 
)

Creates a distribution with first (dimension % n_chunks) chunks larger by 1 element.

Template Parameters
Indinteger type for indexing the array
Parameters
dimensionnumber of elements in array
n_chunksnumber of chunks to subdivide the array into
Returns

◆ remove_duplicates()

template<typename X , typename Y , typename Z , class EqualX , class EqualY , class EqualZ >
std::tuple< std::vector< std::tuple< size_t, size_t, size_t > >, std::vector< X >, std::vector< Y >, std::vector< Z > > molpro::linalg::array::util::remove_duplicates ( const std::list< std::tuple< X, Y, Z > > &  reg,
EqualX  equal_x,
EqualY  equal_y,
EqualZ  equal_z 
)

Find duplicates references to x and y arrays and store unique elements in a separate vector.

Vector of scalars is returned complete without truncation. The register becomes a vector of pairs, first element of a pair containing index of x array in the vector of unique x arrays, the second is for y arrays.

Returns
Returns the new register in terms of x and y indices, vectors of unique x and y arrays, and vector of all scalars.

◆ select()

template<class X , typename value_type , typename std::enable_if< std::is_compound< value_type >::value, value_type >::type * = nullptr>
auto molpro::linalg::array::util::select ( size_t  n,
const X &  x,
bool  max = false,
bool  ignore_sign = false 
)

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

Template Parameters
Xtype of array, must be iterable complete array
value_typetype for X elements
value_type_abstype for absolute value of value_type
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 x,y product

◆ select_max_dot()

template<class X , class Y , typename value_type , typename value_type_abs >
auto molpro::linalg::array::util::select_max_dot ( size_t  n,
const X &  x,
const Y &  y 
)

Select n indices with largest by absolute value contributions to the dot product.

Template Parameters
Xtype of left array, must be iterable complete array
Ytype of right array, must be iterable complete array
value_typetype for product of X and Y elements
value_type_abstype for absolute value of value_type
Parameters
nnumber of indices to select
xleft array
yright array
Returns
map of indices and corresponding x,y product

◆ select_max_dot_broadcast()

std::map< size_t, double > molpro::linalg::array::util::select_max_dot_broadcast ( size_t  n,
std::map< size_t, double > &  local_selection,
MPI_Comm  communicator 
)

◆ select_max_dot_iter_sparse()

template<class X , class Y , typename value_type , typename value_type_abs >
auto molpro::linalg::array::util::select_max_dot_iter_sparse ( size_t  n,
const X &  x,
const Y &  y 
)

Select n indices with largest by absolute value contributions to the dot product.

Template Parameters
Xtype of left array, must be random access container
Ytype of right array, must be a sparse array
value_typetype for product of X and Y elements
value_type_abstype for absolute value of value_type
Parameters
nnumber of indices to select
xleft array
yright array
Returns
map of indices and corresponding x,y product

◆ select_max_dot_sparse()

template<class X , class Y , typename value_type , typename value_type_abs >
auto molpro::linalg::array::util::select_max_dot_sparse ( size_t  n,
const X &  x,
const Y &  y 
)

Select n indices with largest by absolute value contributions to the dot product.

Template Parameters
Xtype of left array, must be a sparse array
Ytype of right array, must be a sparse array
value_typetype for product of X and Y elements
value_type_abstype for absolute value of value_type
Parameters
nnumber of indices to select
xleft array
yright array
Returns
map of indices and corresponding x,y product

◆ select_sparse()

template<class X , typename value_type >
auto molpro::linalg::array::util::select_sparse ( size_t  n,
const X &  x,
bool  max = false,
bool  ignore_sign = false 
)

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

Template Parameters
Xtype of array, must be iterable complete array
value_typetype for X elements
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 x,y product

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

Template Parameters
Xtype of array, must be iterable complete array
value_typetype for X elements
value_type_abstype for absolute value of value_type
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 x,y product

◆ swap()

void molpro::linalg::array::util::swap ( DistrFlags x,
DistrFlags y 
)

◆ temp_file_name()

fs::path molpro::linalg::array::util::temp_file_name ( const fs::path &  base_name,
const std::string &  suffix 
)

Returns random file name for a temporary file.

Parameters
base_namebase name for the file, after which a random character string will follow
suffixsuffix to add to the file name e.g. ".hdf5"

Variable Documentation

◆ is_array_v

template<typename T >
constexpr bool molpro::linalg::array::util::is_array_v = std::is_array<T>::value || is_std_array_v<T>
constexpr

◆ is_std_array_v

template<typename T >
constexpr bool molpro::linalg::array::util::is_std_array_v = is_std_array<T>::value
constexpr

◆ s_mutex

std::mutex molpro::linalg::array::util::s_mutex

◆ s_temp_file_name_count

int molpro::linalg::array::util::s_temp_file_name_count = 0