Documentation
BipartiteIndexList is a set of 2 IndexList objects that can be viewed as a single concatenated range
Definition at line 364 of file index_list.h.
Public Types | |
typedef std::string | value_type |
Type used to store the individual string indices. More... | |
typedef const value_type & | const_reference |
A read-only reference to a string index. More... | |
typedef container_type::const_iterator | const_iterator |
A read-only random-access iterator. More... | |
typedef std::size_t | size_type |
Type used for indexing and offsets. More... | |
Public Member Functions | |
BipartiteIndexList ()=default | |
BipartiteIndexList (const std::string str) | |
BipartiteIndexList (const BipartiteIndexList &other)=default | |
BipartiteIndexList & | operator= (const BipartiteIndexList &other)=default |
BipartiteIndexList & | operator= (const std::string &str) |
BipartiteIndexList & | operator*= (const Permutation &p) |
bool | operator== (const BipartiteIndexList &other) const |
operator bool () const | |
Bool conversion. More... | |
bool | operator! () const |
Not operator. More... | |
const_iterator | begin () const |
const_iterator | end () const |
const_reference | at (const size_type n) const |
const_reference | operator[] (const size_type n) const |
auto | positions (const std::string &x) const |
size_type | count (const std::string &x) const |
size_type | dim () const |
size_type | first_size () const |
size_type | second_size () const |
IndexList | first () const |
IndexList | second () const |
size_type | size () const |
const auto & | data () const |
operator value_type () const | |
void | swap (BipartiteIndexList &other) noexcept |
template<typename V , typename = std::enable_if_t<TiledArray::detail::is_range_v<V>>> | |
BipartitePermutation | permutation (const V &other) const |
Computes the permutation to go from other to this instance. More... | |
bool | is_permutation (const BipartiteIndexList &other) const |
Check that this index list is a permutation of other . More... | |
template<typename OuterType , typename InnerType > | |
BipartiteIndexList (OuterType &&outer, InnerType &&inner) | |
Constructor implementing BipartiteIndexList(const value_type&) More... | |
Friends | |
BipartiteIndexList | operator* (const ::TiledArray::Permutation &, const BipartiteIndexList &) |
Member Typedef Documentation
◆ const_iterator
typedef container_type::const_iterator TiledArray::expressions::BipartiteIndexList::const_iterator |
A read-only random-access iterator.
Definition at line 380 of file index_list.h.
◆ const_reference
A read-only reference to a string index.
Definition at line 377 of file index_list.h.
◆ size_type
typedef std::size_t TiledArray::expressions::BipartiteIndexList::size_type |
Type used for indexing and offsets.
Definition at line 383 of file index_list.h.
◆ value_type
typedef std::string TiledArray::expressions::BipartiteIndexList::value_type |
Type used to store the individual string indices.
Definition at line 374 of file index_list.h.
Constructor & Destructor Documentation
◆ BipartiteIndexList() [1/4]
|
default |
Constructs an empty index list.
The default BipartiteIndexList is an empty container. It has no indices (outer or inner). Iterators to the beginning of the container are the same as iterators to the end of the container. After instantiation the only way to add indices to a BipartiteIndexList instance is via copy/move assignment.
- Exceptions
-
None No throw guarantee.
◆ BipartiteIndexList() [2/4]
|
inlineexplicit |
Initializes a BipartiteIndexList by tokenizing a string
This constructor invokes TiledArray::detail::split_index to tokenize str
. To label a rank tensor, str
should contain substrings delimited by commas, e.g., "i,j,k" labels a rank 3 tensor such that mode 0 is "i", mode 1 is "j", and mode 2 is "k". This constructor can also be used to label tensors-of-tensors. To label a rank tensor of rank tensors, str
should contain substrings such that the first are delimited from the last by a semicolon and the first are delimited from each other by commas and the last are delimited from each other by commas, e.g. "i,j,k;l,m" labels a rank 3 tensor of rank 2 tensors such that "i,j,k" label the modes of the outer tensor (mode 0 of the outer tensor is labeled "i", mode 1 "j", and mode 2 "k") and "l,m" label the modes of the inner tensor (mode 0 of the inner tensor will be labeled "l", mode 1 "m").
- Parameters
-
[in] str The string to tokenize.
- Exceptions
-
TiledArray::Exception if str
is not a valid index according to detail::is_valid_index. Strong throw guarantee.
Definition at line 417 of file index_list.h.
◆ BipartiteIndexList() [3/4]
|
default |
Creates a new BipartiteIndexList instance by deep-copying other
- Parameters
-
[in] other The BipartiteIndexList to deep copy.
◆ BipartiteIndexList() [4/4]
|
inline |
Constructor implementing BipartiteIndexList(const value_type&)
Definition at line 819 of file index_list.h.
Member Function Documentation
◆ at()
|
inline |
Returns the n-th string in the index list.
This member function returns the requested string index, n
, throwing if n
is not in the range [0, dim()). Use operator[](size_type) to avoid the in-range check.
- Parameters
-
[in] n The index of the requested mode label. n
should be in the range [0, dim()).
- Returns
- A read-only reference to the requested string index.
- Exceptions
-
std::out_of_range if n
is not in the range [0, dim()). Strong throw guarantee.
Definition at line 550 of file index_list.h.
◆ begin()
|
inline |
Returns a random-access iterator pointing to the first string index.
For a BipartiteIndexList which describes a normal tensor (i.e., not a tensor-of- tensors) the indices are stored such that the first index in the container labels mode 0, the second index labels mode 1, etc. This function returns an iterator which points to the first index (that labeling mode 0) in this instance. If this instance is empty than the resulting iterator is the same as that returned by end()
and should not be dreferenced.
If this instance describes a tensor-of-tensors the indices are stored flattened such that the outer indices appear before the inner indices. The iterator returned by begin()
thus points to the index labeling the 0th mode of the outer tensor.
The iterator resulting from this function is valid until the set of indices managed by this instance is modified.
- Returns
- A read-only iterator pointing to the 0-th mode of the tensor. For tensor-of-tensors the iterator points to the 0-th mode of the outer tensor and will run over the outer modes followed by the modes of the inner tensor.
- Exceptions
-
None No throw guarantee.
Definition at line 514 of file index_list.h.
◆ count()
|
inline |
Returns the number of times annotation x
appears in this instance
This function is used to count the number of times an annotation appears in the set of annotations managed by this instance. A particular annotation can appear more than once, for example in a trace.
- Parameters
-
[in] x The annotation we are searching for.
- Returns
- An unsigned integer in the range [0, dim()) indicating the number of times
x
appears in this instance.
- Exceptions
-
None No throw guarantee.
Definition at line 595 of file index_list.h.
◆ data()
|
inline |
Definition at line 644 of file index_list.h.
◆ dim()
|
inline |
Returns the total number of indices in the index list
This function is just an alias for the size()
member. It returns the the total number of indices in the index list.
- Returns
- The total number of indices in the index list.
- Exceptions
-
None No throw guarantee.
Definition at line 606 of file index_list.h.
◆ end()
|
inline |
Returns a random-access iterator pointing to just past the last index.
For a BipartiteIndexList which describes a normal tensor (i.e., not a tensor-of- tensors) the indices are stored such that the first index in the container labels mode 0, the second index labels mode 1, etc. This function returns an iterator which points to just past the last index in this instance. If this instance is empty than the resulting iterator is the same as that returned by begin()
.
If this instance describes a tensor-of-tensors the indices are stored flattened such that the outer indices appear before the inner indices. The iterator returned by end()
thus points to the just past the last index of the inner tensor.
The iterator resulting from this function is valid until the set of indices managed by this instance is modified. The iterator itself is only a semaphore and should not be dereferenced.
- Returns
- A read-only iterator pointing to just past the last index. For tensor-of-tensors the iterator points to just past the last index of the inner tensor.
- Exceptions
-
None No throw guarantee.
Definition at line 538 of file index_list.h.
◆ first()
|
inline |
Definition at line 627 of file index_list.h.
◆ first_size()
|
inline |
- Returns
- the size of the first sublist
Definition at line 611 of file index_list.h.
◆ is_permutation()
|
inline |
Check that this index list is a permutation of other
.
- Returns
true
if all indices in this index list are inother
, otherwisefalse
.
Definition at line 692 of file index_list.h.
◆ operator bool()
|
inlineexplicit |
Bool conversion.
- Returns
true
if the permutation is not empty, otherwisefalse
.
Definition at line 484 of file index_list.h.
◆ operator value_type()
|
inlineexplicit |
Enables conversion from a BipartiteIndexList to a string
This function will cast the BipartiteIndexList instance to a string, such that mode labels are separated by commas
- Returns
- A string representation of the
Definition at line 805 of file index_list.h.
◆ operator!()
|
inline |
Not operator.
- Returns
true
if the permutation is empty, otherwisefalse
.
Definition at line 489 of file index_list.h.
◆ operator*=()
|
inline |
Applies a permutation, in-place, to the current BipartiteIndexList instance
This function applies the Permutation instance, p
, to the current BipartiteIndexList instance overwriting the already existing state with the permuted state.
- Parameters
-
[in] p The Permutation to apply. p
should be of ranksize()
.
- Returns
- The current instance after applying the permutation.
Definition at line 458 of file index_list.h.
◆ operator=() [1/2]
|
default |
Modifies the current BipartiteIndexList so it contains a deep copy of other
.
The copy-assignment operator for BipartiteIndexList erases any already existing state (and in the process invalidating any references to it) and replaces it with a deep copy of other
. The current instance, containing a deep copy of other
, is then returned to faciliate chaining.
- Parameters
-
[in] other The BipartiteIndexList instance whose state will be copied.
- Returns
- The current instance containing a deep copy of
other's
state.
◆ operator=() [2/2]
|
inline |
Sets the current instance to the BipartiteIndexList constructed from str
- Parameters
-
[in] str a string to be tokenized
- Returns
- Reference to
*this
Definition at line 444 of file index_list.h.
◆ operator==()
|
inline |
Determines if two BipartiteIndexList instances are equivalent
Two BipartiteIndexList instances are equivalent if they contain the same number of indices, the indices are partitioned into inner and outer indices identically, and if the -th index of each instance are equivalent for all . In particular this means BipartiteIndexList instances will compare different if they use different capitalization and/or are permutations of each other.
- Parameters
-
[in] other The BipartiteIndexList instance we are comparing to.
- Returns
- True if the two instances are equivalent and false otherwise.
- Exceptions
-
None No throw guarantee.
Definition at line 476 of file index_list.h.
◆ operator[]()
|
inline |
Returns the n-th string in the index list.
This member function returns the string used to label mode n
of the tensor. Unlike at, no range check is performed and undefined behavior will occur if n
is not in the range [0, dims()).
- Parameters
-
[in] n The index of the requested mode label. n
should be in the range [0, dims()) otherwise undefined behavior will occur.
- Returns
- A read-only reference to the requested string index.
- Exceptions
-
None No throw guarantee.
Definition at line 561 of file index_list.h.
◆ permutation()
|
inline |
Computes the permutation to go from other
to this instance.
The result of this function is a permutation that defines this=p^other
.
- Template Parameters
-
V A container of strings. V
must minimally be forward iterable.
- Parameters
-
[in] other An array that defines a index list
- Returns
- The permutation which can be applied to other to generate this instance.
- Exceptions
-
TiledArray::Exception if the other
does not contain the same number of indices. Strong throw guarantee.TiledArray::Exception if other
does not contain the same indices as this instance. Strong throw guarantee.TiledArray::Exception if other
does not have the same ToT structure as this tensor. Strong throw guarantee.TiledArray::Exception if other
is a ToT permutation such that it mixes outer and inner modes. Strong throw guarantee.
Definition at line 684 of file index_list.h.
◆ positions()
|
inline |
Returns the indices of the modes annotated with x
This function can be thought of as the inverse mapping of at
and operator[]
namely given an annotation, x
, return the modes labeled with x
. For example assume that this instance stores "i,j,k,l"
calling this function with input "i"
would return a container whose only element is 0
, calling this function with "j"
would return a container whose only element is 1
, etc. This function returns a container, and not a single index, in case the annotation labels more than one mode (e.g., in a trace).
- Parameters
-
[in] x The annotation we are looking for.
- Returns
- A random-access container whose length is the number of times that
x
appears in the annotation and whose elements are the modes labeled withx
.
Definition at line 578 of file index_list.h.
◆ second()
|
inline |
Definition at line 629 of file index_list.h.
◆ second_size()
|
inline |
Returns the number of inner indices in the index list
BipartiteIndexList is capable of holding a string labeling a tensor-of-tensors or a normal (non-nested) tensor. For a ToT the indices are partitioned into outer (those for the outer tensor whose elements are tensors) and inner (those for the tensors which are elements of the outer tensor). This function returns the number of inner indices in the provided index. By convention all indices for a normal tensor are outer indices and this function will always return zero.
- Returns
- The total number of inner indices in the managed list of labels.
- Exceptions
-
None No throw guarantee.
Definition at line 625 of file index_list.h.
◆ size()
|
inline |
Returns the total number of indices in the index list
This function returns the total number of indices in the BipartiteIndexList. For a normal, non-nested, tensor this is simply the number of indices. For a tensor-of-tensors the total number of indices is the number of outer indices plus the number of inner indices.
- Returns
- The total number of indices in the index list. For a tensor-of- tensors the total number is the sum of the number of outer indices plus the number of inner indices.
- Exceptions
-
None No throw guarantee.
Definition at line 642 of file index_list.h.
◆ swap()
|
inlinenoexcept |
Swaps the current instance's state with that of other
- Parameters
-
[in] other The instance to swap state with. After this operation, other
will contain this instance's state and this instance will contain other's state.
Definition at line 659 of file index_list.h.
Friends And Related Function Documentation
◆ operator*
|
friend |
Definition at line 780 of file index_list.h.
The documentation for this class was generated from the following file:
- TiledArray/expressions/index_list.h