TiledArray::SparseShape< T > Class Template Reference

Documentation

template<typename T>
class TiledArray::SparseShape< T >

Frobenius-norm-based sparse shape.

Sparse shape uses a Tensor of Frobenius norms to describe the magnitude of the data contained in tiles of an Array object. Because tiles may have an arbitrary size, screening of tiles uses scaled (per-element) Frobenius norms obtained by dividing the tile's Frobenius norm by the tile volume (=its number of elements):

\[ {\rm{shape}}_{ij...} = \frac{\|A_{ij...}\|}{N_i N_j ...} \]

where $ij...$ are tile indices, $\|A_{ij}\|$ is norm of tile $ij...$, and $N_i N_j ...$ is the product of tile $ij...$ in each dimension. Note that such scaled Frobenius norms no longer have the properties of the Frobenius norms such as the submiltiplicativity.

All constructors will zero out tiles whose scaled norms are below the threshold. The screening threshold is accessed via SparseShape:::threshold() ; it is the global, but not immutable. Thus it is possible to screen each operation separately, by changing the screening threshold between each operation.

Warning
If tile's scaled norm is below threshold, its scaled norm is set to to zero and thus lost forever. E.g. shape.scale(1e-10).scale(1e10) does not in general equal shape , whereas shape.scale(1e10).scale(1e-10) does.

Definition at line 74 of file sparse_shape.h.

Public Types

typedef SparseShape< T > SparseShape_
 This object type. More...
 
typedef T value_type
 The norm value type. More...
 
using index1_type = TA_1INDEX_TYPE
 
typedef Tensor< value_type >::size_type size_type
 Size type. More...
 

Public Member Functions

 SparseShape ()
 Default constructor. More...
 
 SparseShape (const value_type &tile_norm, const TiledRange &trange)
 "Dense" Constructor More...
 
 SparseShape (const Tensor< value_type > &tile_norms, const TiledRange &trange, bool do_not_scale=false)
 "Dense" constructor More...
 
template<typename SparseNormSequence , typename = std::enable_if_t< TiledArray::detail::has_member_function_begin_anyreturn< std::decay_t<SparseNormSequence>>::value && TiledArray::detail::has_member_function_end_anyreturn< std::decay_t<SparseNormSequence>>::value>>
 SparseShape (const SparseNormSequence &tile_norms, const TiledRange &trange, bool do_not_scale=false)
 "Sparse" constructor More...
 
 SparseShape (World &world, const Tensor< value_type > &tile_norms, const TiledRange &trange, bool do_not_scale=false)
 Collective "dense" constructor. More...
 
template<typename SparseNormSequence >
 SparseShape (World &world, const SparseNormSequence &tile_norms, const TiledRange &trange)
 Collective "sparse" constructor. More...
 
 SparseShape (const SparseShape< T > &other)
 Copy constructor. More...
 
SparseShape< T > & operator= (const SparseShape< T > &other)
 Copy assignment operator. More...
 
bool validate (const Range &range) const
 Validate shape range. More...
 
template<typename Index >
bool is_zero (const Index &i) const
 Check that a tile is zero. More...
 
float sparsity () const
 Sparsity of the shape. More...
 
template<typename Index >
value_type operator[] (const Index &index) const
 Tile norm accessor. More...
 
template<typename Op >
SparseShape_ transform (Op &&op) const
 Transform the norm tensor with an operation. More...
 
const Tensor< value_type > & data () const
 Data accessor. More...
 
const Tensor< value_type > & tile_norms () const
 Data accessor. More...
 
bool empty () const
 Initialization check. More...
 
SparseShape_ mask (const SparseShape_ &mask_shape) const
 Compute union of two shapes. More...
 
template<typename Index1 , typename Index2 , typename = std::enable_if_t<detail::is_integral_range_v<Index1> && detail::is_integral_range_v<Index2>>>
SparseShape update_block (const Index1 &lower_bound, const Index2 &upper_bound, const SparseShape &other) const
 Creates a copy of this with a sub-block updated with contents of another shape. More...
 
template<typename Index1 , typename Index2 , typename = std::enable_if_t<std::is_integral_v<Index1> && std::is_integral_v<Index2>>>
SparseShape update_block (const std::initializer_list< Index1 > &lower_bound, const std::initializer_list< Index2 > &upper_bound, const SparseShape &other) const
 Creates a copy of this with a sub-block updated with contents of another shape. More...
 
template<typename PairRange , typename = std::enable_if_t<detail::is_gpair_range_v<PairRange>>>
SparseShape update_block (const PairRange &bounds, const SparseShape &other) const
 Creates a copy of this with a sub-block updated with contents of another shape. More...
 
template<typename Index , typename = std::enable_if_t<std::is_integral_v<Index>>>
SparseShape update_block (const std::initializer_list< std::initializer_list< Index >> &bounds, const SparseShape &other) const
 Creates a copy of this with a sub-block updated with contents of another shape. More...
 
bool operator== (const SparseShape< T > &other) const
 Bitwise comparison. More...
 
template<typename Index1 , typename Index2 , typename = std::enable_if_t<detail::is_integral_range_v<Index1> && detail::is_integral_range_v<Index2>>>
SparseShape block (const Index1 &lower_bound, const Index2 &upper_bound) const
 Create a copy of a sub-block of the shape. More...
 
template<typename Index1 , typename Index2 , typename = std::enable_if_t<std::is_integral_v<Index1> && std::is_integral_v<Index2>>>
SparseShape block (const std::initializer_list< Index1 > &lower_bound, const std::initializer_list< Index2 > &upper_bound) const
 Create a copy of a sub-block of the shape. More...
 
template<typename PairRange , typename = std::enable_if_t<detail::is_gpair_range_v<PairRange>>>
SparseShape block (const PairRange &bounds) const
 Create a copy of a sub-block of the shape. More...
 
template<typename Index , typename = std::enable_if_t<std::is_integral_v<Index>>>
SparseShape block (const std::initializer_list< std::initializer_list< Index >> &bounds) const
 Create a copy of a sub-block of the shape. More...
 
template<typename Index1 , typename Index2 , typename Scalar , typename = std::enable_if_t<detail::is_integral_range_v<Index1> && detail::is_integral_range_v<Index2> && detail::is_numeric_v<Scalar>>>
SparseShape block (const Index1 &lower_bound, const Index2 &upper_bound, const Scalar factor) const
 Create a scaled sub-block of the shape. More...
 
template<typename Index1 , typename Index2 , typename Scalar , typename = std::enable_if_t<std::is_integral_v<Index1> && std::is_integral_v<Index2> && detail::is_numeric_v<Scalar>>>
SparseShape block (const std::initializer_list< Index1 > &lower_bound, const std::initializer_list< Index2 > &upper_bound, const Scalar factor) const
 Create a scaled sub-block of the shape. More...
 
template<typename PairRange , typename Scalar , typename = std::enable_if_t<detail::is_numeric_v<Scalar> && detail::is_gpair_range_v<PairRange>>>
SparseShape block (const PairRange &bounds, const Scalar factor) const
 Create a scaled sub-block of the shape. More...
 
template<typename Index , typename Scalar , typename = std::enable_if_t<detail::is_numeric_v<Scalar> && std::is_integral_v<Index>>>
SparseShape block (const std::initializer_list< std::initializer_list< Index >> &bounds, const Scalar factor) const
 Create a scaled sub-block of the shape. More...
 
template<typename Index1 , typename Index2 , typename = std::enable_if_t<detail::is_integral_range_v<Index1> && detail::is_integral_range_v<Index2>>>
SparseShape block (const Index1 &lower_bound, const Index2 &upper_bound, const Permutation &perm) const
 Create a permuted sub-block of the shape. More...
 
template<typename Index1 , typename Index2 , typename = std::enable_if_t<std::is_integral_v<Index1> && std::is_integral_v<Index2>>>
SparseShape block (const std::initializer_list< Index1 > &lower_bound, const std::initializer_list< Index2 > &upper_bound, const Permutation &perm) const
 Create a permuted sub-block of the shape. More...
 
template<typename PairRange , typename = std::enable_if_t<detail::is_gpair_range_v<PairRange>>>
SparseShape block (const PairRange &bounds, const Permutation &perm) const
 Create a permuted sub-block of the shape. More...
 
template<typename Index , typename = std::enable_if_t<std::is_integral_v<Index>>>
SparseShape block (const std::initializer_list< std::initializer_list< Index >> &bounds, const Permutation &perm) const
 Create a permuted sub-block of the shape. More...
 
template<typename Index1 , typename Index2 , typename Scalar , typename = std::enable_if_t<detail::is_integral_range_v<Index1> && detail::is_integral_range_v<Index2> && detail::is_numeric_v<Scalar>>>
SparseShape block (const Index1 &lower_bound, const Index2 &upper_bound, const Scalar factor, const Permutation &perm) const
 Create a permuted scaled sub-block of the shape. More...
 
template<typename Index1 , typename Index2 , typename Scalar , typename = std::enable_if_t<std::is_integral_v<Index1> && std::is_integral_v<Index2> && detail::is_numeric_v<Scalar>>>
SparseShape block (const std::initializer_list< Index1 > &lower_bound, const std::initializer_list< Index2 > &upper_bound, const Scalar factor, const Permutation &perm) const
 Create a permuted scaled sub-block of the shape. More...
 
template<typename PairRange , typename Scalar , typename = std::enable_if_t<detail::is_numeric_v<Scalar> && detail::is_gpair_range_v<PairRange>>>
SparseShape block (const PairRange &bounds, const Scalar factor, const Permutation &perm) const
 Create a permuted scaled sub-block of the shape. More...
 
template<typename Index , typename Scalar , typename = std::enable_if_t<detail::is_numeric_v<Scalar> && std::is_integral_v<Index>>>
SparseShape block (const std::initializer_list< std::initializer_list< Index >> &bounds, const Scalar factor, const Permutation &perm) const
 Create a permuted scaled sub-block of the shape. More...
 
SparseShape_ perm (const Permutation &perm) const
 Create a permuted shape of this shape. More...
 
template<typename Scalar , typename = std::enable_if_t<detail::is_numeric_v<Scalar>>>
SparseShape_ scale (const Scalar factor) const
 Scale shape. More...
 
template<typename Factor >
SparseShape_ scale (const Factor factor, const Permutation &perm) const
 Scale and permute shape. More...
 
SparseShape_ add (const SparseShape_ &other) const
 Add shapes. More...
 
SparseShape_ add (const SparseShape_ &other, const Permutation &perm) const
 Add and permute shapes. More...
 
template<typename Factor >
SparseShape_ add (const SparseShape_ &other, const Factor factor) const
 Add and scale shapes. More...
 
template<typename Factor >
SparseShape_ add (const SparseShape_ &other, const Factor factor, const Permutation &perm) const
 Add, scale, and permute shapes. More...
 
SparseShape_ add (value_type value) const
 
SparseShape_ add (const value_type value, const Permutation &perm) const
 
SparseShape_ subt (const SparseShape_ &other) const
 
SparseShape_ subt (const SparseShape_ &other, const Permutation &perm) const
 
template<typename Factor >
SparseShape_ subt (const SparseShape_ &other, const Factor factor) const
 
template<typename Factor >
SparseShape_ subt (const SparseShape_ &other, const Factor factor, const Permutation &perm) const
 
SparseShape_ subt (const value_type value) const
 
SparseShape_ subt (const value_type value, const Permutation &perm) const
 
SparseShape_ mult (const SparseShape_ &other) const
 
SparseShape_ mult (const SparseShape_ &other, const Permutation &perm) const
 
template<typename Factor >
SparseShape_ mult (const SparseShape_ &other, const Factor factor) const
 
template<typename Factor >
SparseShape_ mult (const SparseShape_ &other, const Factor factor, const Permutation &perm) const
 
template<typename Factor >
SparseShape_ gemm (const SparseShape_ &other, const Factor factor, const math::GemmHelper &gemm_helper) const
 
template<typename Factor >
SparseShape_ gemm (const SparseShape_ &other, const Factor factor, const math::GemmHelper &gemm_helper, const Permutation &perm) const
 
template<typename Archive , typename std::enable_if< madness::archive::is_input_archive< Archive >::value >::type * = nullptr>
void serialize (const Archive &ar)
 
template<typename Archive , typename std::enable_if< madness::archive::is_output_archive< Archive >::value >::type * = nullptr>
void serialize (const Archive &ar) const
 

Static Public Member Functions

static constexpr bool is_dense ()
 Check density. More...
 
static value_type threshold ()
 Threshold accessor. More...
 
static void threshold (const value_type thresh)
 Set threshold to thresh. More...
 

Member Typedef Documentation

◆ index1_type

template<typename T >
using TiledArray::SparseShape< T >::index1_type = TA_1INDEX_TYPE

Definition at line 78 of file sparse_shape.h.

◆ size_type

template<typename T >
typedef Tensor<value_type>::size_type TiledArray::SparseShape< T >::size_type

Size type.

Definition at line 81 of file sparse_shape.h.

◆ SparseShape_

template<typename T >
typedef SparseShape<T> TiledArray::SparseShape< T >::SparseShape_

This object type.

Definition at line 76 of file sparse_shape.h.

◆ value_type

template<typename T >
typedef T TiledArray::SparseShape< T >::value_type

The norm value type.

Definition at line 77 of file sparse_shape.h.

Constructor & Destructor Documentation

◆ SparseShape() [1/7]

template<typename T >
TiledArray::SparseShape< T >::SparseShape ( )
inline

Default constructor.

Construct a shape with no data.

Definition at line 274 of file sparse_shape.h.

◆ SparseShape() [2/7]

template<typename T >
TiledArray::SparseShape< T >::SparseShape ( const value_type tile_norm,
const TiledRange trange 
)
inline

"Dense" Constructor

This constructor set the tile norms to the same value.

Parameters
tile_normthe value of the (per-element) norm for every tile
trangeThe tiled range of the tensor
Note
this ctor does not scale tile norms
if tile_norm is less than the threshold then all tile norms are set to zero

Definition at line 284 of file sparse_shape.h.

◆ SparseShape() [3/7]

template<typename T >
TiledArray::SparseShape< T >::SparseShape ( const Tensor< value_type > &  tile_norms,
const TiledRange trange,
bool  do_not_scale = false 
)
inline

"Dense" constructor

This constructor will scale the tile norms, i.e. multiply each tile norm by the inverse of its volume.

Parameters
tile_normsThe Frobenius norm of tiles by default
trangeThe tiled range of the tensor
do_not_scaleif true, assume that the tile norms in tile_norms are already scaled

Definition at line 299 of file sparse_shape.h.

Here is the call graph for this function:

◆ SparseShape() [4/7]

template<typename T >
template<typename SparseNormSequence , typename = std::enable_if_t< TiledArray::detail::has_member_function_begin_anyreturn< std::decay_t<SparseNormSequence>>::value && TiledArray::detail::has_member_function_end_anyreturn< std::decay_t<SparseNormSequence>>::value>>
TiledArray::SparseShape< T >::SparseShape ( const SparseNormSequence &  tile_norms,
const TiledRange trange,
bool  do_not_scale = false 
)
inline

"Sparse" constructor

This constructor uses tile norms given as a sparse tensor, represented as a sequence of {index,value_type} data. The tile norms are scaled by the inverse of the corresponding tile's volumes.

Template Parameters
SparseNormSequencethe sequence of std::pair<index,value_type> objects, where index is a directly-addressable sequence indices.
Parameters
tile_normsThe Frobenius norm of tiles
trangeThe tiled range of the tensor
do_not_scaleif true, assume that the tile norms in tile_norms are already scaled

Definition at line 333 of file sparse_shape.h.

◆ SparseShape() [5/7]

template<typename T >
TiledArray::SparseShape< T >::SparseShape ( World &  world,
const Tensor< value_type > &  tile_norms,
const TiledRange trange,
bool  do_not_scale = false 
)
inline

Collective "dense" constructor.

This constructor uses tile norms given as a dense tensor. The tile norms are max-reduced across all processes (via an all reduce). Next, the norms are scaled by the inverse of the corresponding tile's volumes.

Parameters
worldThe world where the shape will live
tile_normsThe Frobenius norm of tiles by default; expected to contain nonzeros for this rank's subset of tiles, or be replicated.
trangeThe tiled range of the tensor
do_not_scaleif true, assume that the tile norms in tile_norms are already scaled

Definition at line 369 of file sparse_shape.h.

Here is the call graph for this function:

◆ SparseShape() [6/7]

template<typename T >
template<typename SparseNormSequence >
TiledArray::SparseShape< T >::SparseShape ( World &  world,
const SparseNormSequence &  tile_norms,
const TiledRange trange 
)
inline

Collective "sparse" constructor.

This constructor uses tile norms given as a sparse tensor, represented as a sequence of {index,value_type} data. The tile norms are scaled to per-element norms by dividing each norm by the tile's volume. Lastly, the norms are max-reduced across all processors.

Template Parameters
SparseNormSequencethe sequence of std::pair<index,value_type> objects, where index is a directly-addressable sequence of integers.
Parameters
worldThe world where the shape will live
tile_normsThe Frobenius norm of tiles; expected to contain nonzeros for this rank's subset of tiles, or be replicated.
trangeThe tiled range of the tensor

Definition at line 405 of file sparse_shape.h.

◆ SparseShape() [7/7]

template<typename T >
TiledArray::SparseShape< T >::SparseShape ( const SparseShape< T > &  other)
inline

Copy constructor.

Shallow copy of other.

Parameters
otherThe other shape object to be copied

Definition at line 416 of file sparse_shape.h.

Member Function Documentation

◆ add() [1/6]

template<typename T >
SparseShape_ TiledArray::SparseShape< T >::add ( const SparseShape_ other) const
inline

Add shapes.

Construct a new sum of shapes as:

\[ {(\rm{result})}_{ij...} = (\rm{this})_{ij...} + (\rm{other})_{ij...} \]

Parameters
otherThe shape to be added to this shape
Returns
A sum of shapes

Definition at line 1179 of file sparse_shape.h.

Here is the call graph for this function:

◆ add() [2/6]

template<typename T >
template<typename Factor >
SparseShape_ TiledArray::SparseShape< T >::add ( const SparseShape_ other,
const Factor  factor 
) const
inline

Add and scale shapes.

Construct a new sum of shapes as:

\[ {(\rm{result})}_{ij...} = |(\rm{factor})| ((\rm{this})_{ij...} + (\rm{other})_{ij...}) \]

Template Parameters
FactorThe scaling factor type
Note
expression abs(Factor) must be well defined (by default, std::abs will be used)
Parameters
otherThe shape to be added to this shape
factorThe scaling factor
Returns
A scaled sum of shapes

Definition at line 1240 of file sparse_shape.h.

Here is the call graph for this function:

◆ add() [3/6]

template<typename T >
template<typename Factor >
SparseShape_ TiledArray::SparseShape< T >::add ( const SparseShape_ other,
const Factor  factor,
const Permutation perm 
) const
inline

Add, scale, and permute shapes.

Construct a new sum of shapes as:

\[ {(\rm{result})}_{ij...} = |(\rm{factor})| ((\rm{this})_{ij...} + (\rm{other})_{ij...}) \]

Template Parameters
FactorThe scaling factor type
Note
expression abs(Factor) must be well defined (by default, std::abs will be used)
Parameters
otherThe shape to be added to this shape
factorThe scaling factor
permThe permutation that is applied to the result
Returns
A scaled and permuted sum of shapes

Definition at line 1274 of file sparse_shape.h.

Here is the call graph for this function:

◆ add() [4/6]

template<typename T >
SparseShape_ TiledArray::SparseShape< T >::add ( const SparseShape_ other,
const Permutation perm 
) const
inline

Add and permute shapes.

Construct a new sum of shapes as:

\[ {(\rm{result})}_{ji...} = \rm{perm}(i,j) (\rm{this})_{ij...} + (\rm{other})_{ij...} \]

Parameters
otherThe shape to be added to this shape
permThe permutation that is applied to the result
Returns
the new shape, equals this + other

Definition at line 1208 of file sparse_shape.h.

Here is the call graph for this function:

◆ add() [5/6]

template<typename T >
SparseShape_ TiledArray::SparseShape< T >::add ( const value_type  value,
const Permutation perm 
) const
inline

Definition at line 1363 of file sparse_shape.h.

Here is the call graph for this function:

◆ add() [6/6]

template<typename T >
SparseShape_ TiledArray::SparseShape< T >::add ( value_type  value) const
inline

Definition at line 1299 of file sparse_shape.h.

Here is the call graph for this function:

◆ block() [1/16]

template<typename T >
template<typename Index1 , typename Index2 , typename = std::enable_if_t<detail::is_integral_range_v<Index1> && detail::is_integral_range_v<Index2>>>
SparseShape TiledArray::SparseShape< T >::block ( const Index1 &  lower_bound,
const Index2 &  upper_bound 
) const
inline

Create a copy of a sub-block of the shape.

Template Parameters
Index1An integral range type
Index2An integral range type
Parameters
lower_boundThe lower bound of the sub-block
upper_boundThe upper bound of the sub-block

Definition at line 829 of file sparse_shape.h.

Here is the caller graph for this function:

◆ block() [2/16]

template<typename T >
template<typename Index1 , typename Index2 , typename = std::enable_if_t<detail::is_integral_range_v<Index1> && detail::is_integral_range_v<Index2>>>
SparseShape TiledArray::SparseShape< T >::block ( const Index1 &  lower_bound,
const Index2 &  upper_bound,
const Permutation perm 
) const
inline

Create a permuted sub-block of the shape.

Template Parameters
Index1An integral range type
Index2An integral range type
Parameters
lower_boundThe lower bound of the sub-block
upper_boundThe upper bound of the sub-block
permpermutation to apply
Note
permutation is not fused into construction

Definition at line 965 of file sparse_shape.h.

Here is the call graph for this function:

◆ block() [3/16]

template<typename T >
template<typename Index1 , typename Index2 , typename Scalar , typename = std::enable_if_t<detail::is_integral_range_v<Index1> && detail::is_integral_range_v<Index2> && detail::is_numeric_v<Scalar>>>
SparseShape TiledArray::SparseShape< T >::block ( const Index1 &  lower_bound,
const Index2 &  upper_bound,
const Scalar  factor 
) const
inline

Create a scaled sub-block of the shape.

Template Parameters
Index1An integral range type
Index2An integral range type
ScalarA numeric type
Note
expression abs(Scalar) must be well defined (by default, std::abs will be used)
Parameters
lower_boundThe lower bound of the sub-block
upper_boundThe upper bound of the sub-block
factorthe scaling factor

Definition at line 890 of file sparse_shape.h.

◆ block() [4/16]

template<typename T >
template<typename Index1 , typename Index2 , typename Scalar , typename = std::enable_if_t<detail::is_integral_range_v<Index1> && detail::is_integral_range_v<Index2> && detail::is_numeric_v<Scalar>>>
SparseShape TiledArray::SparseShape< T >::block ( const Index1 &  lower_bound,
const Index2 &  upper_bound,
const Scalar  factor,
const Permutation perm 
) const
inline

Create a permuted scaled sub-block of the shape.

Template Parameters
Index1An integral range type
Index2An integral range type
ScalarA numeric type
Note
expression abs(Scalar) must be well defined (by default, std::abs will be used)
Parameters
lower_boundThe lower bound of the sub-block
upper_boundThe upper bound of the sub-block
factorthe scaling factor
permpermutation to apply
Note
permutation is not fused into construction

Definition at line 1029 of file sparse_shape.h.

Here is the call graph for this function:

◆ block() [5/16]

template<typename T >
template<typename PairRange , typename = std::enable_if_t<detail::is_gpair_range_v<PairRange>>>
SparseShape TiledArray::SparseShape< T >::block ( const PairRange &  bounds) const
inline

Create a copy of a sub-block of the shape.

Template Parameters
PairRangeType representing a range of generalized pairs (see TiledArray::detail::is_gpair_v )
Parameters
boundsThe {lower,upper} bounds of the sub-block

Definition at line 859 of file sparse_shape.h.

◆ block() [6/16]

template<typename T >
template<typename PairRange , typename = std::enable_if_t<detail::is_gpair_range_v<PairRange>>>
SparseShape TiledArray::SparseShape< T >::block ( const PairRange &  bounds,
const Permutation perm 
) const
inline

Create a permuted sub-block of the shape.

Template Parameters
PairRangeType representing a range of generalized pairs (see TiledArray::detail::is_gpair_v )
Parameters
boundsA range of {lower,upper} bounds for each dimension
permpermutation to apply
Note
permutation is not fused into construction

Definition at line 995 of file sparse_shape.h.

Here is the call graph for this function:

◆ block() [7/16]

template<typename T >
template<typename PairRange , typename Scalar , typename = std::enable_if_t<detail::is_numeric_v<Scalar> && detail::is_gpair_range_v<PairRange>>>
SparseShape TiledArray::SparseShape< T >::block ( const PairRange &  bounds,
const Scalar  factor 
) const
inline

Create a scaled sub-block of the shape.

Template Parameters
PairRangeType representing a range of generalized pairs (see TiledArray::detail::is_gpair_v )
ScalarA numeric type
Note
expression abs(Scalar) must be well defined (by default, std::abs will be used)
Parameters
boundsA range of {lower,upper} bounds for each dimension
factorthe scaling factor

Definition at line 929 of file sparse_shape.h.

◆ block() [8/16]

template<typename T >
template<typename PairRange , typename Scalar , typename = std::enable_if_t<detail::is_numeric_v<Scalar> && detail::is_gpair_range_v<PairRange>>>
SparseShape TiledArray::SparseShape< T >::block ( const PairRange &  bounds,
const Scalar  factor,
const Permutation perm 
) const
inline

Create a permuted scaled sub-block of the shape.

Template Parameters
PairRangeType representing a range of generalized pairs (see TiledArray::detail::is_gpair_v )
ScalarA numeric type
Note
expression abs(Scalar) must be well defined (by default, std::abs will be used)
Parameters
boundsA range of {lower,upper} bounds for each dimension
factorthe scaling factor
permpermutation to apply
Note
permutation is not fused into construction

Definition at line 1068 of file sparse_shape.h.

◆ block() [9/16]

template<typename T >
template<typename Index1 , typename Index2 , typename = std::enable_if_t<std::is_integral_v<Index1> && std::is_integral_v<Index2>>>
SparseShape TiledArray::SparseShape< T >::block ( const std::initializer_list< Index1 > &  lower_bound,
const std::initializer_list< Index2 > &  upper_bound 
) const
inline

Create a copy of a sub-block of the shape.

Template Parameters
Index1An integral type
Index2An integral type
Parameters
lower_boundThe lower bound of the sub-block
upper_boundThe upper bound of the sub-block

Definition at line 845 of file sparse_shape.h.

Here is the call graph for this function:

◆ block() [10/16]

template<typename T >
template<typename Index1 , typename Index2 , typename = std::enable_if_t<std::is_integral_v<Index1> && std::is_integral_v<Index2>>>
SparseShape TiledArray::SparseShape< T >::block ( const std::initializer_list< Index1 > &  lower_bound,
const std::initializer_list< Index2 > &  upper_bound,
const Permutation perm 
) const
inline

Create a permuted sub-block of the shape.

Template Parameters
Index1An integral type
Index2An integral type
Parameters
lower_boundThe lower bound of the sub-block
upper_boundThe upper bound of the sub-block
permpermutation to apply
Note
permutation is not fused into construction

Definition at line 981 of file sparse_shape.h.

Here is the call graph for this function:

◆ block() [11/16]

template<typename T >
template<typename Index1 , typename Index2 , typename Scalar , typename = std::enable_if_t<std::is_integral_v<Index1> && std::is_integral_v<Index2> && detail::is_numeric_v<Scalar>>>
SparseShape TiledArray::SparseShape< T >::block ( const std::initializer_list< Index1 > &  lower_bound,
const std::initializer_list< Index2 > &  upper_bound,
const Scalar  factor 
) const
inline

Create a scaled sub-block of the shape.

Template Parameters
Index1An integral type
Index2An integral type
ScalarA numeric type
Note
expression abs(Scalar) must be well defined (by default, std::abs will be used)
Parameters
lower_boundThe lower bound of the sub-block
upper_boundThe upper bound of the sub-block

Definition at line 911 of file sparse_shape.h.

◆ block() [12/16]

template<typename T >
template<typename Index1 , typename Index2 , typename Scalar , typename = std::enable_if_t<std::is_integral_v<Index1> && std::is_integral_v<Index2> && detail::is_numeric_v<Scalar>>>
SparseShape TiledArray::SparseShape< T >::block ( const std::initializer_list< Index1 > &  lower_bound,
const std::initializer_list< Index2 > &  upper_bound,
const Scalar  factor,
const Permutation perm 
) const
inline

Create a permuted scaled sub-block of the shape.

Template Parameters
Index1An integral type
Index2An integral type
ScalarA numeric type
Note
expression abs(Scalar) must be well defined (by default, std::abs will be used)
Parameters
lower_boundThe lower bound of the sub-block
upper_boundThe upper bound of the sub-block
factorthe scaling factor
permpermutation to apply
Note
permutation is not fused into construction

Definition at line 1050 of file sparse_shape.h.

Here is the call graph for this function:

◆ block() [13/16]

template<typename T >
template<typename Index , typename = std::enable_if_t<std::is_integral_v<Index>>>
SparseShape TiledArray::SparseShape< T >::block ( const std::initializer_list< std::initializer_list< Index >> &  bounds) const
inline

Create a copy of a sub-block of the shape.

Template Parameters
IndexAn integral type
Parameters
boundsA range of {lower,upper} bounds for each dimension

Definition at line 870 of file sparse_shape.h.

◆ block() [14/16]

template<typename T >
template<typename Index , typename = std::enable_if_t<std::is_integral_v<Index>>>
SparseShape TiledArray::SparseShape< T >::block ( const std::initializer_list< std::initializer_list< Index >> &  bounds,
const Permutation perm 
) const
inline

Create a permuted sub-block of the shape.

Template Parameters
IndexAn integral type
Parameters
boundsA range of {lower,upper} bounds for each dimension
permpermutation to apply
Note
permutation is not fused into construction

Definition at line 1007 of file sparse_shape.h.

Here is the call graph for this function:

◆ block() [15/16]

template<typename T >
template<typename Index , typename Scalar , typename = std::enable_if_t<detail::is_numeric_v<Scalar> && std::is_integral_v<Index>>>
SparseShape TiledArray::SparseShape< T >::block ( const std::initializer_list< std::initializer_list< Index >> &  bounds,
const Scalar  factor 
) const
inline

Create a scaled sub-block of the shape.

Template Parameters
IndexAn integral type
ScalarA numeric type
Note
expression abs(Scalar) must be well defined (by default, std::abs will be used)
Parameters
boundsA range of {lower,upper} bounds for each dimension
factorthe scaling factor

Definition at line 946 of file sparse_shape.h.

◆ block() [16/16]

template<typename T >
template<typename Index , typename Scalar , typename = std::enable_if_t<detail::is_numeric_v<Scalar> && std::is_integral_v<Index>>>
SparseShape TiledArray::SparseShape< T >::block ( const std::initializer_list< std::initializer_list< Index >> &  bounds,
const Scalar  factor,
const Permutation perm 
) const
inline

Create a permuted scaled sub-block of the shape.

Template Parameters
IndexAn integral type
ScalarA numeric type
Note
expression abs(Scalar) must be well defined (by default, std::abs will be used)
Parameters
boundsA range of {lower,upper} bounds for each dimension
factorthe scaling factor
permpermutation to apply
Note
permutation is not fused into construction

Definition at line 1089 of file sparse_shape.h.

◆ data()

template<typename T >
const Tensor<value_type>& TiledArray::SparseShape< T >::data ( ) const
inline

Data accessor.

Returns
A const reference to the Tensor object that stores the scaled (per-element) Frobenius norms of tiles

Definition at line 528 of file sparse_shape.h.

Here is the caller graph for this function:

◆ empty()

template<typename T >
bool TiledArray::SparseShape< T >::empty ( ) const
inline

Initialization check.

Returns
true when this shape has been initialized.

Definition at line 549 of file sparse_shape.h.

Here is the caller graph for this function:

◆ gemm() [1/2]

template<typename T >
template<typename Factor >
SparseShape_ TiledArray::SparseShape< T >::gemm ( const SparseShape_ other,
const Factor  factor,
const math::GemmHelper gemm_helper 
) const
inline
Template Parameters
FactorThe scaling factor type
Note
expression abs(Factor) must be well defined (by default, std::abs will be used)

Definition at line 1459 of file sparse_shape.h.

Here is the call graph for this function:

◆ gemm() [2/2]

template<typename T >
template<typename Factor >
SparseShape_ TiledArray::SparseShape< T >::gemm ( const SparseShape_ other,
const Factor  factor,
const math::GemmHelper gemm_helper,
const Permutation perm 
) const
inline
Template Parameters
FactorThe scaling factor type
Note
expression abs(Factor) must be well defined (by default, std::abs will be used)

Definition at line 1557 of file sparse_shape.h.

Here is the call graph for this function:

◆ is_dense()

template<typename T >
static constexpr bool TiledArray::SparseShape< T >::is_dense ( )
inlinestaticconstexpr

Check density.

Returns
true

Definition at line 463 of file sparse_shape.h.

◆ is_zero()

template<typename T >
template<typename Index >
bool TiledArray::SparseShape< T >::is_zero ( const Index &  i) const
inline

Check that a tile is zero.

Template Parameters
IndexThe type of the index
Returns
false

Definition at line 455 of file sparse_shape.h.

◆ mask()

template<typename T >
SparseShape_ TiledArray::SparseShape< T >::mask ( const SparseShape_ mask_shape) const
inline

Compute union of two shapes.

Parameters
maskThe input shape, hard zeros are used to mask the output.
Returns
A shape that is masked by the mask.

Definition at line 555 of file sparse_shape.h.

Here is the call graph for this function:

◆ mult() [1/4]

template<typename T >
SparseShape_ TiledArray::SparseShape< T >::mult ( const SparseShape_ other) const
inline

Definition at line 1392 of file sparse_shape.h.

Here is the call graph for this function:

◆ mult() [2/4]

template<typename T >
template<typename Factor >
SparseShape_ TiledArray::SparseShape< T >::mult ( const SparseShape_ other,
const Factor  factor 
) const
inline
Template Parameters
FactorThe scaling factor type
Note
expression abs(Factor) must be well defined (by default, std::abs will be used)

Definition at line 1421 of file sparse_shape.h.

Here is the call graph for this function:

◆ mult() [3/4]

template<typename T >
template<typename Factor >
SparseShape_ TiledArray::SparseShape< T >::mult ( const SparseShape_ other,
const Factor  factor,
const Permutation perm 
) const
inline
Template Parameters
FactorThe scaling factor type
Note
expression abs(Factor) must be well defined (by default, std::abs will be used)

Definition at line 1439 of file sparse_shape.h.

Here is the call graph for this function:

◆ mult() [4/4]

template<typename T >
SparseShape_ TiledArray::SparseShape< T >::mult ( const SparseShape_ other,
const Permutation perm 
) const
inline

Definition at line 1404 of file sparse_shape.h.

Here is the call graph for this function:

◆ operator=()

template<typename T >
SparseShape<T>& TiledArray::SparseShape< T >::operator= ( const SparseShape< T > &  other)
inline

Copy assignment operator.

Shallow copy of other.

Parameters
otherThe other shape object to be copied
Returns
A reference to this object.

Definition at line 431 of file sparse_shape.h.

◆ operator==()

template<typename T >
bool TiledArray::SparseShape< T >::operator== ( const SparseShape< T > &  other) const
inline

Bitwise comparison.

Parameters
othera SparseShape object
Returns
true if this object and other object are bitwise identical

Definition at line 697 of file sparse_shape.h.

◆ operator[]()

template<typename T >
template<typename Index >
value_type TiledArray::SparseShape< T >::operator[] ( const Index &  index) const
inline

Tile norm accessor.

Template Parameters
IndexThe index type
Parameters
indexThe index of the tile norm to retrieve
Returns
The (scaled) norm of the tile at index

Definition at line 489 of file sparse_shape.h.

◆ perm()

template<typename T >
SparseShape_ TiledArray::SparseShape< T >::perm ( const Permutation perm) const
inline

Create a permuted shape of this shape.

Parameters
permThe permutation to be applied
Returns
A new, permuted shape

Definition at line 1102 of file sparse_shape.h.

Here is the caller graph for this function:

◆ scale() [1/2]

template<typename T >
template<typename Factor >
SparseShape_ TiledArray::SparseShape< T >::scale ( const Factor  factor,
const Permutation perm 
) const
inline

Scale and permute shape.

Compute a new scaled shape is computed as:

\[ {(\rm{result})}_{ji...} = \rm{perm}(j,i) |(\rm{factor})| (\rm{this})_{ij...} \]

Template Parameters
FactorThe scaling factor type
Note
expression abs(Factor) must be well defined (by default, std::abs will be used)
Parameters
factorThe scaling factor
permThe permutation that will be applied to this tensor.
Returns
A new, scaled-and-permuted shape

Definition at line 1150 of file sparse_shape.h.

Here is the call graph for this function:

◆ scale() [2/2]

template<typename T >
template<typename Scalar , typename = std::enable_if_t<detail::is_numeric_v<Scalar>>>
SparseShape_ TiledArray::SparseShape< T >::scale ( const Scalar  factor) const
inline

Scale shape.

Construct a new scaled shape as:

\[ {(\rm{result})}_{ij...} = |(\rm{factor})| (\rm{this})_{ij...} \]

Template Parameters
ScalarA numeric type
Note
expression abs(Scalar) must be well defined (by default, std::abs will be used)
Parameters
factorThe scaling factor
Returns
A new, scaled shape

Definition at line 1120 of file sparse_shape.h.

Here is the call graph for this function:

◆ serialize() [1/2]

template<typename T >
template<typename Archive , typename std::enable_if< madness::archive::is_input_archive< Archive >::value >::type * = nullptr>
void TiledArray::SparseShape< T >::serialize ( const Archive &  ar)
inline

Definition at line 1566 of file sparse_shape.h.

◆ serialize() [2/2]

template<typename T >
template<typename Archive , typename std::enable_if< madness::archive::is_output_archive< Archive >::value >::type * = nullptr>
void TiledArray::SparseShape< T >::serialize ( const Archive &  ar) const
inline

Definition at line 1579 of file sparse_shape.h.

◆ sparsity()

template<typename T >
float TiledArray::SparseShape< T >::sparsity ( ) const
inline

Sparsity of the shape.

Returns
The fraction of tiles that are zero.

Definition at line 468 of file sparse_shape.h.

◆ subt() [1/6]

template<typename T >
SparseShape_ TiledArray::SparseShape< T >::subt ( const SparseShape_ other) const
inline

Definition at line 1369 of file sparse_shape.h.

Here is the call graph for this function:

◆ subt() [2/6]

template<typename T >
template<typename Factor >
SparseShape_ TiledArray::SparseShape< T >::subt ( const SparseShape_ other,
const Factor  factor 
) const
inline

Definition at line 1376 of file sparse_shape.h.

Here is the call graph for this function:

◆ subt() [3/6]

template<typename T >
template<typename Factor >
SparseShape_ TiledArray::SparseShape< T >::subt ( const SparseShape_ other,
const Factor  factor,
const Permutation perm 
) const
inline

Definition at line 1381 of file sparse_shape.h.

Here is the call graph for this function:

◆ subt() [4/6]

template<typename T >
SparseShape_ TiledArray::SparseShape< T >::subt ( const SparseShape_ other,
const Permutation perm 
) const
inline

Definition at line 1371 of file sparse_shape.h.

Here is the call graph for this function:

◆ subt() [5/6]

template<typename T >
SparseShape_ TiledArray::SparseShape< T >::subt ( const value_type  value) const
inline

Definition at line 1386 of file sparse_shape.h.

Here is the call graph for this function:

◆ subt() [6/6]

template<typename T >
SparseShape_ TiledArray::SparseShape< T >::subt ( const value_type  value,
const Permutation perm 
) const
inline

Definition at line 1388 of file sparse_shape.h.

Here is the call graph for this function:

◆ threshold() [1/2]

template<typename T >
static value_type TiledArray::SparseShape< T >::threshold ( )
inlinestatic

Threshold accessor.

Returns
The current threshold

Definition at line 476 of file sparse_shape.h.

◆ threshold() [2/2]

template<typename T >
static void TiledArray::SparseShape< T >::threshold ( const value_type  thresh)
inlinestatic

Set threshold to thresh.

Parameters
threshThe new threshold

Definition at line 481 of file sparse_shape.h.

◆ tile_norms()

template<typename T >
const Tensor<value_type>& TiledArray::SparseShape< T >::tile_norms ( ) const
inline

Data accessor.

Returns
A const reference to the Tensor object that stores the Frobenius norms of tiles

Definition at line 534 of file sparse_shape.h.

◆ transform()

template<typename T >
template<typename Op >
SparseShape_ TiledArray::SparseShape< T >::transform ( Op &&  op) const
inline

Transform the norm tensor with an operation.

Returns
A deep copy of the norms of the object having performed the operation Op. Op should take a const ref to a Tensor<T> and return a Tensor<T> Since the input tile norms have already been scaled the output norms will be identically scaled, e.g. when Op is an identity operation the output SparseShape data will have the same values as this.

Definition at line 504 of file sparse_shape.h.

Here is the call graph for this function:

◆ update_block() [1/4]

template<typename T >
template<typename Index1 , typename Index2 , typename = std::enable_if_t<detail::is_integral_range_v<Index1> && detail::is_integral_range_v<Index2>>>
SparseShape TiledArray::SparseShape< T >::update_block ( const Index1 &  lower_bound,
const Index2 &  upper_bound,
const SparseShape< T > &  other 
) const
inline

Creates a copy of this with a sub-block updated with contents of another shape.

Template Parameters
Index1An integral range type
Index2An integral range type
Parameters
lower_boundThe lower bound of the sub-block to be updated
upper_boundThe upper bound of the sub-block to be updated
otherThe shape that will be used to update the sub-block
Returns
A new sparse shape object where the sub-block defined by lower_bound and upper_bound contains the data result_tile_norms of other.

Definition at line 593 of file sparse_shape.h.

Here is the call graph for this function:

◆ update_block() [2/4]

template<typename T >
template<typename PairRange , typename = std::enable_if_t<detail::is_gpair_range_v<PairRange>>>
SparseShape TiledArray::SparseShape< T >::update_block ( const PairRange &  bounds,
const SparseShape< T > &  other 
) const
inline

Creates a copy of this with a sub-block updated with contents of another shape.

Template Parameters
PairRangeType representing a range of generalized pairs (see TiledArray::detail::is_gpair_v )
Parameters
boundsThe {lower,upper} bounds of the sub-block
otherThe shape that will be used to update the sub-block
Returns
A new sparse shape object where the sub-block defined by lower_bound and upper_bound contains the data result_tile_norms of other.

Definition at line 651 of file sparse_shape.h.

Here is the call graph for this function:

◆ update_block() [3/4]

template<typename T >
template<typename Index1 , typename Index2 , typename = std::enable_if_t<std::is_integral_v<Index1> && std::is_integral_v<Index2>>>
SparseShape TiledArray::SparseShape< T >::update_block ( const std::initializer_list< Index1 > &  lower_bound,
const std::initializer_list< Index2 > &  upper_bound,
const SparseShape< T > &  other 
) const
inline

Creates a copy of this with a sub-block updated with contents of another shape.

Template Parameters
Index1An integral type
Index2An integral type
Parameters
lower_boundThe lower bound of the sub-block to be updated
upper_boundThe upper bound of the sub-block to be updated
otherThe shape that will be used to update the sub-block
Returns
A new sparse shape object where the sub-block defined by lower_bound and upper_bound contains the data result_tile_norms of other.

Definition at line 632 of file sparse_shape.h.

◆ update_block() [4/4]

template<typename T >
template<typename Index , typename = std::enable_if_t<std::is_integral_v<Index>>>
SparseShape TiledArray::SparseShape< T >::update_block ( const std::initializer_list< std::initializer_list< Index >> &  bounds,
const SparseShape< T > &  other 
) const
inline

Creates a copy of this with a sub-block updated with contents of another shape.

Template Parameters
IndexAn integral type
Parameters
boundsThe {lower,upper} bounds of the sub-block
otherThe shape that will be used to update the sub-block
Returns
A new sparse shape object where the sub-block defined by lower_bound and upper_bound contains the data result_tile_norms of other.

Definition at line 686 of file sparse_shape.h.

◆ validate()

template<typename T >
bool TiledArray::SparseShape< T >::validate ( const Range range) const
inline

Validate shape range.

Returns
true when range matches the range of this shape

Definition at line 445 of file sparse_shape.h.


The documentation for this class was generated from the following file: