|
MPQC
3.0.0-alpha
|
Implements a block sparse tensor. More...
#include <chemistry/qc/lmp2/sma.h>
Public Types | |
| typedef IndicesLess< N > | Compare |
|
typedef std::multimap < BlockInfo< N >, double *, Compare > | blockmap_t |
|
typedef std::multimap < BlockInfo< N >, double *, IndexListLess< N > > | cached_blockmap_t |
|
typedef AVLMMap< BlockInfo< N > , double *, Compare > | blockmap_t |
|
typedef AVLMMap< BlockInfo< N > , double *, IndexListLess< N > > | cached_blockmap_t |
|
typedef __gnu_cxx::hash_map < BlockInfo< N >, double *, BlockInfoHash< N > , BlockInfoEqual< N > > | blockhash_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. | |
| 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. | |
| 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 | bound () const |
| void | set_bound (double b) |
| double | tolerance () const |
| void | set_tolerance (double t) |
| void | clear () |
| Make this array store nothing. | |
| const blockmap_t & | blockmap () const |
| Return the block map. | |
| const blockhash_t & | blockhash () const |
| Return the block hash. | |
| 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. | |
| blockmap_t::value_type & | add_allocated_block (const BlockInfo< N > &b) |
| Adds block b. | |
| blockmap_t::value_type & | add_zeroed_block (const BlockInfo< N > &b) |
| Adds block b. | |
| void | remove_block (const BlockInfo< N > &b) |
| Removes a block. | |
| 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. | |
| blockmap_t::iterator | add_new_unallocated_block (const BlockInfo< N > &b) |
| Adds block b. | |
| void | add_all_unallocated_blocks () |
| Adds all possible blocks to give a dense array. | |
| blockmap_t::iterator | initial_hint () |
| Returns an initial hint. | |
| 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. | |
| void | parallel_union (const sc::Ref< sc::MessageGrp > &grp) |
| Makes the block distribution the same on all processes. | |
| void | replicated_from_distributed (const sc::Ref< sc::MessageGrp > &, const Array< N > &) |
| Convert a distributed array to a replicated array. | |
| 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. | |
| 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. | |
| 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.
| sc::sma2::Array< N >::Array | ( | const std::string & | name = "", |
| double | tol = DBL_EPSILON |
||
| ) | [inline] |
This does not initialize any indices.
The set_index member must be called for all indices before the array is used.
| sc::sma2::Array< N >::Array | ( | const Range & | index, |
| const std::string & | name = "", |
||
| double | tol = DBL_EPSILON |
||
| ) | [inline] |
Initialize all N indices to index.
| sc::sma2::Array< N >::Array | ( | const Range & | i0, |
| const Range & | i1, | ||
| const std::string & | name = "", |
||
| double | tol = DBL_EPSILON |
||
| ) | [inline] |
Initialize range 0 to i0, and the rest to i1.
| sc::sma2::Array< N >::Array | ( | const Range & | i0, |
| const Range & | i1, | ||
| const Range & | i2, | ||
| const std::string & | name = "", |
||
| double | tol = DBL_EPSILON |
||
| ) | [inline] |
Initialize range 0 to i0, 1 to i1, and the rest to i2.
| sc::sma2::Array< N >::Array | ( | const Range & | i0, |
| const Range & | i1, | ||
| const Range & | i2, | ||
| const Range & | i3, | ||
| const std::string & | name = "", |
||
| double | tol = DBL_EPSILON |
||
| ) | [inline] |
Initialize range 0, 1 and 2 to i0, i1, and i2, and the rest to i3.
| sc::sma2::Array< N >::Array | ( | const Range & | i0, |
| const Range & | i1, | ||
| const Range & | i2, | ||
| const Range & | i3, | ||
| const Range & | i4, | ||
| const std::string & | name = "", |
||
| double | tol = DBL_EPSILON |
||
| ) | [inline] |
Initialize range 0, 1, 2, 3, and 4 to i0, i1, i2, i3, and i4, and the rest to i4.
| sc::sma2::Array< N >::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 |
||
| ) | [inline] |
Initialize range 0, 1, 2, 3, 4, and 5 to i0, i1, i2, i3, i4, and i5, and the rest to i5.
| sc::sma2::Array< N >::Array | ( | const Range * | ranges, |
| double | tol = DBL_EPSILON |
||
| ) | [inline] |
Initialize each range to the ranges in the given range array.
| void sc::sma2::Array< N >::add_all_unallocated_blocks | ( | ) | [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.
| blockmap_t::value_type& sc::sma2::Array< N >::add_allocated_block | ( | const BlockInfo< N > & | b | ) | [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.
| blockmap_t::iterator sc::sma2::Array< N >::add_new_unallocated_block | ( | const typename blockmap_t::iterator & | hint, |
| const BlockInfo< N > & | b | ||
| ) | [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().
| blockmap_t::iterator sc::sma2::Array< N >::add_new_unallocated_block | ( | const BlockInfo< N > & | b | ) | [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.
| blockmap_t::value_type& sc::sma2::Array< N >::add_unallocated_block | ( | const BlockInfo< N > & | b | ) | [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< N >::operator|=().
| blockmap_t::value_type& sc::sma2::Array< N >::add_zeroed_block | ( | const BlockInfo< N > & | b | ) | [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.
| void sc::sma2::Array< N >::allocate_blocks | ( | ) | [inline] |
Allocate storage for all blocks if storage has not already been allocated.
Referenced by sc::sma2::Array< 6 >::assign(), sc::sma2::Array< 6 >::assign_tol(), and sc::sma2::Array< 6 >::compute_bounds().
| void sc::sma2::Array< N >::assign | ( | double | val | ) | [inline] |
Assigns the given value to all elements in the array.
Referenced by sc::sma2::Array< 6 >::zero().
| void sc::sma2::Array< N >::assign_all | ( | const Array< N > & | a | ) | [inline] |
Assigns this to 'a', and keeps all blocks.
| void sc::sma2::Array< N >::assign_tol | ( | const Array< N > & | a, |
| double | tol | ||
| ) | [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=().
| double sc::sma2::Array< N >::block_max_abs | ( | typename blockmap_t::const_iterator & | b | ) | const [inline] |
Find maximum absolute value of elements in a block.
Referenced by sc::sma2::Array< 6 >::init_blocks(), and sc::sma2::Array< 6 >::max_abs_element().
| int sc::sma2::Array< N >::block_size | ( | const BlockInfo< N > & | bi | ) | const [inline] |
Return size of the given block.
Referenced by sc::sma2::Array< 6 >::add_allocated_block(), sc::sma2::Array< 6 >::add_zeroed_block(), sc::sma2::Array< 6 >::allocate_blocks(), sc::sma2::Array< 6 >::assign(), sc::sma2::Array< 6 >::block_max_abs(), sc::sma2::Array< 6 >::compute_bounds(), sc::sma2::Array< N >::distributed_from_distributed(), sc::sma2::Array< 6 >::n_element(), sc::sma2::Array< 6 >::operator*=(), and sc::sma2::Array< N >::replicated_from_distributed().
| void sc::sma2::Array< N >::clear | ( | ) | [inline] |
Make this array store nothing.
Referenced by sc::sma2::Array< 6 >::add_all_unallocated_blocks(), sc::sma2::Array< N >::distributed_from_distributed(), sc::sma2::Array< 6 >::init_blocks(), and sc::sma2::Array< 6 >::operator*=().
| void sc::sma2::Array< N >::clear_blockmap_cache | ( | ) | [inline] |
Get rid of cached blockmaps.
Referenced by sc::sma2::Array< 6 >::clear().
| void sc::sma2::Array< N >::compute_bounds | ( | ) | [inline] |
Computes the bound for each block.
Referenced by sc::sma2::Array< 6 >::operator*=().
| void sc::sma2::Array< N >::deallocate_blocks | ( | ) | [inline] |
Deallocate storage for all blocks.
| int& sc::sma2::Array< N >::debug | ( | ) | [inline] |
Set/get the debug level.
| 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.
References sc::sma2::Array< N >::block_size(), sc::sma2::BlockDistrib< N >::block_to_node(), sc::sma2::Array< N >::clear(), sc::sma2::Array< N >::indices(), sc::MessageGrp::me(), sc::MessageGrp::n(), and sc::sma2::Array< N >::n_element_allocated().
| const Range& sc::sma2::Array< N >::index | ( | int | i | ) | const [inline] |
Gets the i'th Range.
Referenced by sc::sma2::Array< 6 >::add_all_unallocated_blocks(), sc::sma2::Array< 6 >::add_allocated_block(), sc::sma2::Array< 6 >::add_new_unallocated_block(), sc::sma2::Array< 6 >::add_unallocated_block(), sc::sma2::Array< 6 >::add_zeroed_block(), and sc::sma2::ContractPart< N >::operator|=().
| const Range* sc::sma2::Array< N >::indices | ( | ) | const [inline] |
Gets the Range array.
Referenced by sc::sma2::Array< N >::distributed_from_distributed(), and sc::sma2::Array< 6 >::init_blocks().
| void sc::sma2::Array< N >::init_blocks | ( | const Array< N > & | a, |
| double | tol | ||
| ) | [inline] |
Initialize the stored blocks to be the same as those in a.
Referenced by sc::sma2::Array< 6 >::assign_tol(), and sc::sma2::Array< 6 >::init_blocks().
| void sc::sma2::Array< N >::init_blocks | ( | const Array< N > & | a | ) | [inline] |
Initialize the stored blocks to be the same as those in a.
| blockmap_t::iterator sc::sma2::Array< N >::initial_hint | ( | ) | [inline] |
Returns an initial hint.
Basically, it is just used to initialize a blockmap::iterator to a valid value.
| int sc::sma2::Array< N >::n_block | ( | ) | const [inline] |
Returns the number of blocks.
| size_t sc::sma2::Array< N >::n_element | ( | ) | const [inline] |
Returns the number of elements contained in blocks.
Referenced by sc::sma2::Array< 6 >::allocate_blocks().
| size_t sc::sma2::Array< N >::n_element_allocated | ( | ) | const [inline] |
Returns the number of elements contained in blocks.
Referenced by sc::sma2::Array< N >::distributed_from_distributed().
| 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.
References sc::Timer::enter(), and sc::Timer::exit().
| 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.
References sc::Timer::enter(), sc::Timer::exit(), sc::MessageGrp::me(), and sc::MessageGrp::n().
| void sc::sma2::Array< N >::print_local | ( | std::ostream & | o = sc::ExEnv::outn() | ) | const [inline] |
Print the array.
References sc::sma2::BlockIter< N >::ready(), and sc::sma2::BlockIter< N >::start().
| void sc::sma2::Array< N >::remove_block | ( | const BlockInfo< N > & | b | ) | [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.
References sc::sma2::Array< N >::block_size(), sc::Timer::enter(), sc::Timer::exit(), sc::MessageGrp::me(), and sc::MessageGrp::n().
| void sc::sma2::Array< N >::set_index | ( | int | i, |
| const Range & | idx | ||
| ) | [inline] |
Sets the i'th Range to index.
Referenced by sc::sma2::Array< 6 >::set_indices().
| void sc::sma2::Array< N >::set_indices | ( | const Range * | r | ) | [inline] |
Initialize each range to the ranges in the given range array.
Referenced by sc::sma2::Array< 6 >::Array(), and sc::sma2::Array< 6 >::init_blocks().
| void sc::sma2::Array< N >::set_use_blockmap_cache | ( | bool | ubmc | ) | [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.
| void sc::sma2::Array< N >::zero | ( | ) | [inline] |
Zeros the array.