TiledArray::expressions::BipartiteIndexList Class Reference

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_typeconst_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
 
BipartiteIndexListoperator= (const BipartiteIndexList &other)=default
 
BipartiteIndexListoperator= (const std::string &str)
 
BipartiteIndexListoperator*= (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

Type used for indexing and offsets.

Definition at line 383 of file index_list.h.

◆ 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]

TiledArray::expressions::BipartiteIndexList::BipartiteIndexList ( )
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
NoneNo throw guarantee.
Here is the caller graph for this function:

◆ BipartiteIndexList() [2/4]

TiledArray::expressions::BipartiteIndexList::BipartiteIndexList ( const std::string  str)
inlineexplicit

Initializes a BipartiteIndexList by tokenizing a string

This constructor invokes TiledArray::detail::split_index to tokenize str. To label a rank $n$ tensor, str should contain $n$ substrings delimited by $(n-1)$ 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 $n$ tensor of rank $m$ tensors, str should contain $(n + m)$ substrings such that the first $n$ are delimited from the last $m$ by a semicolon and the first $n$ are delimited from each other by $(n-1)$ commas and the last $m$ are delimited from each other by $(m-1)$ 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]strThe string to tokenize.
Exceptions
TiledArray::Exceptionif 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]

TiledArray::expressions::BipartiteIndexList::BipartiteIndexList ( const BipartiteIndexList other)
default

Creates a new BipartiteIndexList instance by deep-copying other

Parameters
[in]otherThe BipartiteIndexList to deep copy.

◆ BipartiteIndexList() [4/4]

template<typename OuterType , typename InnerType >
TiledArray::expressions::BipartiteIndexList::BipartiteIndexList ( OuterType &&  outer,
InnerType &&  inner 
)
inline

Constructor implementing BipartiteIndexList(const value_type&)

Definition at line 819 of file index_list.h.

Here is the call graph for this function:

Member Function Documentation

◆ at()

const_reference TiledArray::expressions::BipartiteIndexList::at ( const size_type  n) const
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]nThe 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_rangeif n is not in the range [0, dim()). Strong throw guarantee.

Definition at line 550 of file index_list.h.

◆ begin()

const_iterator TiledArray::expressions::BipartiteIndexList::begin ( ) const
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
NoneNo throw guarantee.

Definition at line 514 of file index_list.h.

Here is the caller graph for this function:

◆ count()

size_type TiledArray::expressions::BipartiteIndexList::count ( const std::string &  x) const
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]xThe 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
NoneNo throw guarantee.

Definition at line 595 of file index_list.h.

Here is the call graph for this function:

◆ data()

const auto& TiledArray::expressions::BipartiteIndexList::data ( ) const
inline

Definition at line 644 of file index_list.h.

◆ dim()

size_type TiledArray::expressions::BipartiteIndexList::dim ( ) const
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
NoneNo throw guarantee.

Definition at line 606 of file index_list.h.

Here is the call graph for this function:

◆ end()

const_iterator TiledArray::expressions::BipartiteIndexList::end ( ) const
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
NoneNo throw guarantee.

Definition at line 538 of file index_list.h.

Here is the caller graph for this function:

◆ first()

IndexList TiledArray::expressions::BipartiteIndexList::first ( ) const
inline

Definition at line 627 of file index_list.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ first_size()

size_type TiledArray::expressions::BipartiteIndexList::first_size ( ) const
inline
Returns
the size of the first sublist

Definition at line 611 of file index_list.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_permutation()

bool TiledArray::expressions::BipartiteIndexList::is_permutation ( const BipartiteIndexList other) const
inline

Check that this index list is a permutation of other.

Returns
true if all indices in this index list are in other, otherwise false.

Definition at line 692 of file index_list.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator bool()

TiledArray::expressions::BipartiteIndexList::operator bool ( ) const
inlineexplicit

Bool conversion.

Returns
true if the permutation is not empty, otherwise false.

Definition at line 484 of file index_list.h.

◆ operator value_type()

TiledArray::expressions::BipartiteIndexList::operator value_type ( ) const
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.

Here is the call graph for this function:

◆ operator!()

bool TiledArray::expressions::BipartiteIndexList::operator! ( ) const
inline

Not operator.

Returns
true if the permutation is empty, otherwise false.

Definition at line 489 of file index_list.h.

◆ operator*=()

BipartiteIndexList& TiledArray::expressions::BipartiteIndexList::operator*= ( const Permutation p)
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]pThe Permutation to apply. p should be of rank size().
Returns
The current instance after applying the permutation.

Definition at line 458 of file index_list.h.

Here is the call graph for this function:

◆ operator=() [1/2]

BipartiteIndexList& TiledArray::expressions::BipartiteIndexList::operator= ( const BipartiteIndexList other)
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]otherThe BipartiteIndexList instance whose state will be copied.
Returns
The current instance containing a deep copy of other's state.

◆ operator=() [2/2]

BipartiteIndexList& TiledArray::expressions::BipartiteIndexList::operator= ( const std::string &  str)
inline

Sets the current instance to the BipartiteIndexList constructed from str

Parameters
[in]stra string to be tokenized
Returns
Reference to *this

Definition at line 444 of file index_list.h.

Here is the call graph for this function:

◆ operator==()

bool TiledArray::expressions::BipartiteIndexList::operator== ( const BipartiteIndexList other) const
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 $i$-th index of each instance are equivalent for all $i$. In particular this means BipartiteIndexList instances will compare different if they use different capitalization and/or are permutations of each other.

Parameters
[in]otherThe BipartiteIndexList instance we are comparing to.
Returns
True if the two instances are equivalent and false otherwise.
Exceptions
NoneNo throw guarantee.

Definition at line 476 of file index_list.h.

◆ operator[]()

const_reference TiledArray::expressions::BipartiteIndexList::operator[] ( const size_type  n) const
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]nThe 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
NoneNo throw guarantee.

Definition at line 561 of file index_list.h.

◆ permutation()

template<typename V , typename = std::enable_if_t<TiledArray::detail::is_range_v<V>>>
BipartitePermutation TiledArray::expressions::BipartiteIndexList::permutation ( const V &  other) const
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
VA container of strings. V must minimally be forward iterable.
Parameters
[in]otherAn array that defines a index list
Returns
The permutation which can be applied to other to generate this instance.
Exceptions
TiledArray::Exceptionif the other does not contain the same number of indices. Strong throw guarantee.
TiledArray::Exceptionif other does not contain the same indices as this instance. Strong throw guarantee.
TiledArray::Exceptionif other does not have the same ToT structure as this tensor. Strong throw guarantee.
TiledArray::Exceptionif 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ positions()

auto TiledArray::expressions::BipartiteIndexList::positions ( const std::string &  x) const
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]xThe 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 with x.

Definition at line 578 of file index_list.h.

Here is the call graph for this function:

◆ second()

IndexList TiledArray::expressions::BipartiteIndexList::second ( ) const
inline

Definition at line 629 of file index_list.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ second_size()

size_type TiledArray::expressions::BipartiteIndexList::second_size ( ) const
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
NoneNo throw guarantee.

Definition at line 625 of file index_list.h.

Here is the caller graph for this function:

◆ size()

size_type TiledArray::expressions::BipartiteIndexList::size ( ) const
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
NoneNo throw guarantee.

Definition at line 642 of file index_list.h.

Here is the caller graph for this function:

◆ swap()

void TiledArray::expressions::BipartiteIndexList::swap ( BipartiteIndexList other)
inlinenoexcept

Swaps the current instance's state with that of other

Parameters
[in]otherThe 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.

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator*

BipartiteIndexList operator* ( const ::TiledArray::Permutation p,
const BipartiteIndexList v 
)
friend

Definition at line 780 of file index_list.h.


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