Autodocs Iterator
-
template<class BasisU1 = danceq::internal::BasisU1<danceq::internal::ContainerTable<danceq::internal::State<128, 2, uint64_t>>>>
class BasisIterator The BasisIterator class provides an easy way to handle the Basis.
Template parameters
class BasisU1: The only template parameter is BasisU1.
Default: danceq:: BasisU1 < ContainerTable <danceq:: State <128,2,uint64_t>>>
Things to know
An instance can be easily generated from the BasisU1, see here.
The underlying State class can be accessed via
BasisIterator::state_class
.The debugging level can be adjusted from 0 (no debugging) to 10 (maximal debugging):
#define dbug_level 10; // 10 maximal debugging, 0 is no debugging
Easy handling:
// basis is BasisU1 instance // Using begin() and end() for(auto it = basis.begin(); it < basis.end(); ++it){ std::cout << *it << std::endl; } // Using first() and last() for(auto it = basis.first(); it <= basis.last(); ++it){ std::cout << *it << std::endl; }
Public Types
-
using state_class = typename BasisU1::state_class
State class.
State class can be retrieved from the iterator:
// Definition of classes using State = danceq::State<256,4>; using Container = danceq::internal::ContainerTable<State>; using Basis = danceq::internal::BasisU1<Container>; using BasisIterator = danceq::internal::BasisIterator<Basis>; // This equivalent to: State state; BasisIterator::state_class state;
-
using basis_class = BasisU1
Basis class.
Basis class can be retrieved from the iterator:
// Definition of classes using State = danceq::State<256,4>; using Container = danceq::internal::ContainerTable<State>; using Basis = danceq::internal::BasisU1<Container>; using BasisIterator = danceq::internal::BasisIterator<Basis>; // This equivalent to: Basis basis; BasisIterator::basis_class basis;
Public Functions
-
BasisIterator(const BasisU1 *basisptr_, typename BasisIterator<BasisU1>::state_class &state_)
Constructor with State.
Constructs a BasisIterator for the given BasisU1 from a given State.
-
BasisIterator(const BasisU1 *basisptr_, uint64_t index_, bool trigger_error = true)
Constructor with index.
Constructs a BasisIterator for the given BasisU1 from a given index. If trigger_error is
true
an error is thrown if index_ does not refer to a valid State. This is required to generate an Iterator pointing toend()
in cpp which is not a valid State.
-
BasisIterator<BasisU1> &operator++()
Incrementing of the iterator by one.
Function calls increment from the BasisU1. The last State is mapped to the first State.
auto it = basis.begin(); std::cout << "First element: " << *it << std::endl; ++it; std::cout << "Second element: " << *it << std::endl;
-
BasisIterator<BasisU1> &operator--()
Decrementing of the iterator by one.
Function calls decrement from the BasisU1. The first State is mapped to the last State.
auto it = basis.last(); std::cout << "Last element: " << *it << std::endl; --it; std::cout << "Penultimate element: " << *it << std::endl;
-
BasisIterator<BasisU1> operator+(const uint64_t index_) const
Adding an index to the BasisIterator.
Functions returns a BasisIterator pointing to the State, \(\vert\Psi_i\rangle\), with i = index (current index) + index_ (input index).
- Parameters:
index_ – Index to be added
- Returns:
BasisIterator pointing to i
-
BasisIterator<BasisU1> operator+(const BasisIterator<BasisU1> &basisiterator) const
Adding a BasisIterator to the BasisIterator.
Functions returns a BasisIterator pointing to the State, \(\vert\Psi_i\rangle\), with i = index (current index) + basisiterator.index (input index).
- Parameters:
basisiterator – BasisIterator to be added
- Returns:
BasisIterator pointing to i
-
BasisIterator<BasisU1> operator-(const uint64_t index_) const
Subtracting an index to the BasisIterator.
Functions returns a BasisIterator pointing to the State, \(\vert\Psi_i\rangle\), with i = index (current index) - index_ (input index).
- Parameters:
index_ – Index to be subtracted
- Returns:
BasisIterator pointing to i
-
BasisIterator<BasisU1> operator-(const BasisIterator<BasisU1> &basisiterator) const
Subtracting a BasisIterator to the BasisIterator.
Functions returns a BasisIterator pointing to the State, \(\vert\Psi_i\rangle\), with i = index (current index) - basisiterator.index (input index).
- Parameters:
basisiterator – BasisIterator to be subtracted
- Returns:
BasisIterator pointing to i
-
bool operator!=(const BasisIterator<BasisU1> &basisiterator) const
Compares two instances.
The comparison is done using the index.
- Parameters:
basisiterator – BasisIterator to be compared
- Returns:
false
if both instances are equal, otherwisetrue
-
bool operator==(const BasisIterator<BasisU1> &basisiterator) const
Compares two instances.
The comparison is done using the index.
- Parameters:
basisiterator – BasisIterator to be compared
- Returns:
true
if both instances are equal, otherwisefalse
-
bool operator<(const BasisIterator<BasisU1> &basisiterator) const
Compares two instances.
The comparison is done using the index.
- Parameters:
basisiterator – BasisIterator to be compared
- Returns:
true
ifthis
is lesser, otherwisefalse
-
bool operator<=(const BasisIterator<BasisU1> &basisiterator) const
Compares two instances.
The comparison is done using the index.
- Parameters:
basisiterator – BasisIterator to be compared
- Returns:
true
ifthis
is lesser equal, otherwisefalse
-
bool operator>(const BasisIterator<BasisU1> &basisiterator) const
Compares two instances.
The comparison is done using the index.
- Parameters:
basisiterator – BasisIterator to be compared
- Returns:
true
ifthis
is greater, otherwisefalse
-
bool operator>=(const BasisIterator<BasisU1> &basisiterator) const
Compares two instances.
The comparison is done using the index.
- Parameters:
basisiterator – BasisIterator to be compared
- Returns:
true
ifthis
is greater equal, otherwisefalse
-
BasisIterator<BasisU1>::state_class *operator->()
Dereferencing the state.
- Returns:
Returns Pointer to state
-
BasisIterator<BasisU1>::state_class operator*() const
Dereferencing the state.
- Returns:
Copy of state
-
BasisIterator<BasisU1>::state_class get_state(void) const
Dereferencing the state.
- Returns:
Copy of state
-
uint64_t get_index() const
Returns the index.
- Returns:
index
-
int32_t set_index(uint64_t new_index)
Resets the BasisIterator.
- Parameters:
new_index – New index
- Returns:
error_code
-
int32_t set_state(typename BasisU1::state_class new_state)
Resets the BasisIterator.
- Parameters:
new_state – New state
- Returns:
error_code
-
int64_t distance(const BasisIterator<BasisU1> &basisiterator) const
Returns distance between two BasisIterator.
- Parameters:
basisiterator – Basisiterator for comparison
- Returns:
distance
-
int32_t distance(const BasisIterator<BasisU1> &basisiterator, int64_t *distance) const
Returns distance between two BasisIterator.
- Parameters:
basisiterator – Basisiterator for comparison
distance – Pointer for output
- Returns:
error_code