MPQC
3.0.0-alpha
|
Implements a block sparse tensor. More...
#include <chemistry/qc/lmp2/sma.h>
Public Types | |
typedef IndicesLess< N > | Compare |
typedef AVLMMap< BlockInfo< N >, double *, Compare > | blockmap_t |
typedef AVLMMap< BlockInfo< N >, double *, IndexListLess< N > > | cached_blockmap_t |
Public Member Functions | |
Array (const Array< N > &a) | |
void | assign_tol (const Array< N > &a, double tol) |
Assigns this to 'a', but throws out blocks smaller than tol. More... | |
void | assign_all (const Array< N > &a) |
Assigns this to 'a', and keeps all blocks. | |
Array< N > & | operator= (const Array< N > &a) |
Assigns this to 'a', but throws out small blocks. | |
Array (const std::string &name="", double tol=DBL_EPSILON) | |
This does not initialize any indices. More... | |
void | init (const std::string &name="", double tol=DBL_EPSILON) |
Array (const Range &index, const std::string &name="", double tol=DBL_EPSILON) | |
Initialize all N indices to index. | |
void | init (const Range &index, const std::string &name="", double tol=DBL_EPSILON) |
Array (const Range &i0, const Range &i1, const std::string &name="", double tol=DBL_EPSILON) | |
Initialize range 0 to i0, and the rest to i1. | |
void | init (const Range &i0, const Range &i1, const std::string &name="", double tol=DBL_EPSILON) |
Array (const Range &i0, const Range &i1, const Range &i2, const std::string &name="", double tol=DBL_EPSILON) | |
Initialize range 0 to i0, 1 to i1, and the rest to i2. | |
void | init (const Range &i0, const Range &i1, const Range &i2, const std::string &name="", double tol=DBL_EPSILON) |
Array (const Range &i0, const Range &i1, const Range &i2, const Range &i3, const std::string &name="", double tol=DBL_EPSILON) | |
Initialize range 0, 1 and 2 to i0, i1, and i2, and the rest to i3. | |
void | init (const Range &i0, const Range &i1, const Range &i2, const Range &i3, const std::string &name="", double tol=DBL_EPSILON) |
Array (const Range &i0, const Range &i1, const Range &i2, const Range &i3, const Range &i4, const std::string &name="", double tol=DBL_EPSILON) | |
Initialize range 0, 1, 2, 3, and 4 to i0, i1, i2, i3, and i4, and the rest to i4. | |
void | init (const Range &i0, const Range &i1, const Range &i2, const Range &i3, const Range &i4, const std::string &name="", double tol=DBL_EPSILON) |
Array (const Range &i0, const Range &i1, const Range &i2, const Range &i3, const Range &i4, const Range &i5, const std::string &name="", double tol=DBL_EPSILON) | |
Initialize range 0, 1, 2, 3, 4, and 5 to i0, i1, i2, i3, i4, and i5, and the rest to i5. | |
void | init (const Range &i0, const Range &i1, const Range &i2, const Range &i3, const Range &i4, const Range &i5, const std::string &name="", double tol=DBL_EPSILON) |
Array (const Range *ranges, double tol=DBL_EPSILON) | |
Initialize each range to the ranges in the given range array. | |
double | tolerance () const |
void | set_tolerance (double t) |
void | clear () |
Make this array store nothing. | |
const blockmap_t & | blockmap () const |
Return the block map. | |
void | set_index (int i, const Range &idx) |
Sets the i'th Range to index. | |
void | set_indices (const Range *r) |
Initialize each range to the ranges in the given range array. | |
const Range & | index (int i) const |
Gets the i'th Range. | |
const Range * | indices () const |
Gets the Range array. | |
int | block_size (const BlockInfo< N > &bi) const |
Return size of the given block. | |
blockmap_t::value_type & | add_unallocated_block (const BlockInfo< N > &b) |
Adds block b. More... | |
blockmap_t::value_type & | add_allocated_block (const BlockInfo< N > &b) |
Adds block b. More... | |
blockmap_t::value_type & | add_zeroed_block (const BlockInfo< N > &b) |
Adds block b. More... | |
void | remove_block (const BlockInfo< N > &b) |
Removes a block. More... | |
void | relocate_block (const BlockInfo< N > &b_old, const BlockInfo< N > &b_new) |
blockmap_t::iterator | add_new_unallocated_block (const typename blockmap_t::iterator &hint, const BlockInfo< N > &b) |
Adds block b. More... | |
blockmap_t::iterator | add_new_unallocated_block (const BlockInfo< N > &b) |
Adds block b. More... | |
void | add_all_unallocated_blocks () |
Adds all possible blocks to give a dense array. More... | |
blockmap_t::iterator | initial_hint () |
Returns an initial hint. More... | |
int | n_block () const |
Returns the number of blocks. | |
size_t | n_element () const |
Returns the number of elements contained in blocks. | |
size_t | n_element_allocated () const |
Returns the number of elements contained in blocks. | |
std::string | name () const |
double | max_n_block () |
double | max_n_element () |
void | assign (double val) |
Assigns the given value to all elements in the array. | |
void | zero () |
Zeros the array. | |
void | compute_bounds () |
Computes the bound for each block. | |
void | allocate_blocks () |
Allocate storage for all blocks if storage has not already been allocated. | |
void | deallocate_blocks () |
Deallocate storage for all blocks. | |
ContractPart< N > | operator() () |
ContractPart< N > | operator() (const Index &i1) |
ContractPart< N > | operator() (const Index &i1, const Index &i2) |
ContractPart< N > | operator() (const std::string &i1, const std::string &i2) |
ContractPart< N > | operator() (const Index &i1, const Index &i2, const Index &i3) |
ContractPart< N > | operator() (const std::string &i1, const std::string &i2, const std::string &i3) |
ContractPart< N > | operator() (const Index &i1, const Index &i2, const Index &i3, const Index &i4) |
ContractPart< N > | operator() (const std::string &i1, const std::string &i2, const std::string &i3, const std::string &i4) |
ContractPart< N > | operator() (const Index &i1, const Index &i2, const Index &i3, const Index &i4, const Index &i5) |
ContractPart< N > | operator() (const std::string &i1, const std::string &i2, const std::string &i3, const std::string &i4, const std::string &i5) |
ContractPart< N > | operator() (const Index &i1, const Index &i2, const Index &i3, const Index &i4, const Index &i5, const Index &i6) |
ContractPart< N > | operator() (const std::string &i1, const std::string &i2, const std::string &i3, const std::string &i4, const std::string &i5, const std::string &i6) |
void | operator*= (double f) |
Multiplication by a scalar. | |
void | init_blocks (const Array< N > &a, double tol) |
Initialize the stored blocks to be the same as those in a. | |
void | init_blocks (const Array< N > &a) |
Initialize the stored blocks to be the same as those in a. | |
double | block_max_abs (typename blockmap_t::const_iterator &b) const |
Find maximum absolute value of elements in a block. | |
double | max_abs_element () |
Find maximum absolute value of elements. | |
void | print_local (std::ostream &o=sc::ExEnv::outn()) const |
Print the array. | |
void | print (const sc::Ref< sc::MessageGrp > &grp=0, bool distributed=false, std::ostream &o=sc::ExEnv::outn()) const |
int & | debug () |
Set/get the debug level. | |
const int & | debug () const |
void | read (sc::StateIn &si) |
void | write (sc::StateOut &so) const |
void | parallel_accumulate (const sc::Ref< sc::MessageGrp > &grp) |
Performs a reduce-broadcast on the data. More... | |
void | parallel_union (const sc::Ref< sc::MessageGrp > &grp) |
Makes the block distribution the same on all processes. More... | |
void | replicated_from_distributed (const sc::Ref< sc::MessageGrp > &, const Array< N > &) |
Convert a distributed array to a replicated array. More... | |
void | distributed_from_distributed (const sc::Ref< sc::MessageGrp > &, const BlockDistrib< N > &, Array< N > &, bool clear_source_array=false, bool ignore_block_distrib_throws=false) |
Redistribute an array. More... | |
double | value () |
If this is a scalar (N==0) return the value of the scalar. | |
void | clear_blockmap_cache () |
Get rid of cached blockmaps. | |
void | set_use_blockmap_cache (bool ubmc) |
Used to indicate whether or not a blockmap cache is to be used. More... | |
bool | use_blockmap_cache () const |
Return true if blockmap caches are in use. | |
bool | blockmap_cache_entry_exists (const IndexList &il) |
Return true if the needed blockmap cache entry exists. | |
cached_blockmap_t & | blockmap_cache_entry (const IndexList &il) |
Return a cached blockmap. | |
Static Public Member Functions | |
static int | nindex () |
Return the number of indices. | |
Friends | |
template<int N1> | |
void | remap (typename Array< N1 >::cached_blockmap_t &target, const Array< N1 > &source, const IndexList &fixed, const BlockInfo< N1 > &fixedvals) |
template<int N1> | |
void | remap (Array< N1 > &target, const Array< N1 > &source, const IndexList &il) |
Implements a block sparse tensor.
Array maps the BlockInfo to the block's data using the given Compare type to sort the blocks.
|
inline |
This does not initialize any indices.
The set_index member must be called for all indices before the array is used.
|
inline |
Adds all possible blocks to give a dense array.
The data is not allocated. This cannot be called after storage for the data has been allocated with allocate blocks.
|
inline |
Adds block b.
The data is allocated. This should not be used with add_unallocated_blocks or allocate_blocks. The memory allocated is not initialized.
|
inline |
Adds block b.
The data is not allocated. This cannot be called after storage for the data has been allocated with allocate blocks. This assumes that the new block does not already exist int the multimap.
|
inline |
Adds block b.
The data is not allocated. This cannot be called after storage for the data has been allocated with allocate blocks. This assumes that the new block does not already exist int the multimap. The hint gives a suggested insertion point.
Referenced by sc::sma2::Array< 6 >::add_all_unallocated_blocks().
|
inline |
Adds block b.
The data is not allocated. This cannot be called after storage for the data has been allocated with allocate blocks.
Referenced by sc::sma2::Array< 6 >::init_blocks(), and sc::sma2::ContractPart< Nl >::operator|=().
|
inline |
Adds block b.
The data is allocated. This should not be used with add_unallocated_blocks or allocate_blocks. The data allocated is initialized to zero.
|
inline |
Assigns this to 'a', but throws out blocks smaller than tol.
The tolerance of this will be set to the tolerance of 'a', no matter what tol is.
Referenced by sc::sma2::Array< 6 >::assign_all(), and sc::sma2::Array< 6 >::operator=().
void sc::sma2::Array< N >::distributed_from_distributed | ( | const sc::Ref< sc::MessageGrp > & | msg, |
const BlockDistrib< N > & | distrib, | ||
Array< N > & | d, | ||
bool | clear_source_array = false , |
||
bool | ignore_block_distrib_throws = false |
||
) |
Redistribute an array.
The result is stored in this.
|
inline |
Returns an initial hint.
Basically, it is just used to initialize a blockmap::iterator to a valid value.
void sc::sma2::Array< N >::parallel_accumulate | ( | const sc::Ref< sc::MessageGrp > & | grp | ) |
Performs a reduce-broadcast on the data.
The array must have the same block structure on all processes.
void sc::sma2::Array< N >::parallel_union | ( | const sc::Ref< sc::MessageGrp > & | grp | ) |
Makes the block distribution the same on all processes.
If any processes hold a block, then all will after this call. This does not send any data, only block structure is sent.
|
inline |
Removes a block.
If the data has been allocated, it is deallocated. Does nothing if the block does not exist.
void sc::sma2::Array< N >::replicated_from_distributed | ( | const sc::Ref< sc::MessageGrp > & | msg, |
const Array< N > & | d | ||
) |
Convert a distributed array to a replicated array.
The result is stored in this.
|
inline |
Used to indicate whether or not a blockmap cache is to be used.
Blockmap caches store alternative blockmaps that are used in the contract routine. If a required blockmap is not available, then it is computed. It is also added to the blockmap cache if this is true.