foreach.h File Reference
Include dependency graph for foreach.h:
This graph shows which files directly or indirectly include this file:

Namespaces

 Eigen
 Forward declarations.
 
 TiledArray
 
 TiledArray::detail
 

Enumerations

enum  TiledArray::ShapeReductionMethod { TiledArray::ShapeReductionMethod::Union, TiledArray::ShapeReductionMethod::Intersect }
 

Functions

template<bool inplace = false, typename Op , typename ResultTile , typename ArgTile , typename Policy , typename... ArgTiles>
std::enable_if_t< is_dense_v< Policy >, DistArray< ResultTile, Policy > > TiledArray::detail::foreach (Op &&op, const_if_t< not inplace, DistArray< ArgTile, Policy >> &arg, const DistArray< ArgTiles, Policy > &... args)
 base implementation of dense TiledArray::foreach More...
 
template<bool inplace = false, typename Op , typename ResultTile , typename ArgTile , typename Policy , typename... ArgTiles>
std::enable_if_t<!is_dense_v< Policy >, DistArray< ResultTile, Policy > > TiledArray::detail::foreach (Op &&op, const ShapeReductionMethod shape_reduction, const_if_t< not inplace, DistArray< ArgTile, Policy >> &arg, const DistArray< ArgTiles, Policy > &... args)
 base implementation of sparse TiledArray::foreach More...
 
foreach/foreach_inplace functions

foreach/foreach_inplace is a generalization of std::transform for DistArray objects. Specifically, it applies callable Op to each tile in the argument DistArray object (or objects for the binary foreach/foreach_inplace ). The Op callable either writes the output to the first tile it's given or it produces a new tile (of potentially different type). It also can optionally compute the norm of the result tile. A foreach function produces new DistArray object, whereas foreach_inplace mutates the first DistArray argument "in-place". For dense arrays Op therefore must be callable as

void(ResultTile&, const ArgTiles&...);

For sparse arrays Op must be callable as either

void(ResultTile&, const ArgTiles&...);

or as

real(ResultTile&, const ArgTiles&...);

where real is convertible to the first DistArray argument's shape value; in the latter case the return value is converted to Policy::shape_type::value_type and used to construct the shape of the result, whereas in the former case the shape of the result is computed from the shapes of the DistArray arguments (e.g. assigned to the shape of the first DistArray argument).

Note
foreach/foreach_inplace are collective, with sparse variants synchronizing due to the need to compute and replicate shapes.
template<typename ResultTile , typename ArgTile , typename Policy , typename Op , typename = typename std::enable_if< !std::is_same<ResultTile, ArgTile>::value>::type>
std::enable_if_t< is_dense_v< Policy >, DistArray< ResultTile, Policy > > TiledArray::foreach (const DistArray< ArgTile, Policy > &arg, Op &&op)
 Apply a function to each tile of a dense Array. More...
 
template<typename Tile , typename Policy , typename Op >
std::enable_if_t< is_dense_v< Policy >, DistArray< Tile, Policy > > TiledArray::foreach (const DistArray< Tile, Policy > &arg, Op &&op)
 Apply a function to each tile of a dense Array. More...
 
template<typename Tile , typename Policy , typename Op , typename = typename std::enable_if<!TiledArray::detail::is_array< typename std::decay<Op>::type>::value>::type>
std::enable_if_t< is_dense_v< Policy >, void > TiledArray::foreach_inplace (DistArray< Tile, Policy > &arg, Op &&op, bool fence=true)
 Modify each tile of a dense Array. More...
 
template<typename ResultTile , typename ArgTile , typename Policy , typename Op , typename = typename std::enable_if< !std::is_same<ResultTile, ArgTile>::value>::type>
std::enable_if_t<!is_dense_v< Policy >, DistArray< ResultTile, Policy > > TiledArray::foreach (const DistArray< ArgTile, Policy > arg, Op &&op)
 Apply a function to each tile of a sparse Array. More...
 
template<typename Tile , typename Policy , typename Op >
std::enable_if_t<!is_dense_v< Policy >, DistArray< Tile, Policy > > TiledArray::foreach (const DistArray< Tile, Policy > &arg, Op &&op)
 Apply a function to each tile of a sparse Array. More...
 
template<typename Tile , typename Policy , typename Op , typename = typename std::enable_if<!TiledArray::detail::is_array< typename std::decay<Op>::type>::value>::type>
std::enable_if_t<!is_dense_v< Policy >, void > TiledArray::foreach_inplace (DistArray< Tile, Policy > &arg, Op &&op, bool fence=true)
 Modify each tile of a sparse Array. More...
 
template<typename ResultTile , typename LeftTile , typename RightTile , typename Policy , typename Op , typename = typename std::enable_if< !std::is_same<ResultTile, LeftTile>::value>::type>
std::enable_if_t< is_dense_v< Policy >, DistArray< ResultTile, Policy > > TiledArray::foreach (const DistArray< LeftTile, Policy > &left, const DistArray< RightTile, Policy > &right, Op &&op)
 
template<typename LeftTile , typename RightTile , typename Policy , typename Op >
std::enable_if_t< is_dense_v< Policy >, DistArray< LeftTile, Policy > > TiledArray::foreach (const DistArray< LeftTile, Policy > &left, const DistArray< RightTile, Policy > &right, Op &&op)
 
template<typename LeftTile , typename RightTile , typename Policy , typename Op >
std::enable_if_t< is_dense_v< Policy >, void > TiledArray::foreach_inplace (DistArray< LeftTile, Policy > &left, const DistArray< RightTile, Policy > &right, Op &&op, bool fence=true)
 This function takes two input tiles and put result into the left tile. More...
 
template<typename ResultTile , typename LeftTile , typename RightTile , typename Policy , typename Op , typename = typename std::enable_if< !std::is_same<ResultTile, LeftTile>::value>::type>
std::enable_if_t<!is_dense_v< Policy >, DistArray< ResultTile, Policy > > TiledArray::foreach (const DistArray< LeftTile, Policy > &left, const DistArray< RightTile, Policy > &right, Op &&op, const ShapeReductionMethod shape_reduction=ShapeReductionMethod::Intersect)
 
template<typename LeftTile , typename RightTile , typename Policy , typename Op >
std::enable_if_t<!is_dense_v< Policy >, DistArray< LeftTile, Policy > > TiledArray::foreach (const DistArray< LeftTile, Policy > &left, const DistArray< RightTile, Policy > &right, Op &&op, const ShapeReductionMethod shape_reduction=ShapeReductionMethod::Intersect)
 
template<typename LeftTile , typename RightTile , typename Policy , typename Op >
std::enable_if_t<!is_dense_v< Policy >, void > TiledArray::foreach_inplace (DistArray< LeftTile, Policy > &left, const DistArray< RightTile, Policy > &right, Op &&op, const ShapeReductionMethod shape_reduction=ShapeReductionMethod::Intersect, bool fence=true)
 This function takes two input tiles and put result into the left tile. More...