State enumeration without number conservation
All functions have the name tag _NoU1 which means that the total particle number is not conserved. The number of possible states is simply \(Q^{\textbf{end}-\textbf{start}}\) which is returned by get_dim_NoU1(end-start). The constructor can be found in Constructors with indexing. We provide functions for forward and backward iteration as well as mappings from indices to the physical state and vice versa.
An equivalent set of functions of functions of an inhomogeneous local Hilbert space dimensions can be found below.
Example code:
using State = danceq::internal::State<5,2>; uint64_t start = 1; uint64_t end = 4; State state(0UL, start, end); uint64_t dim = state.get_dim_NoU1(end-start); std::cout << "[main] - dim = " << dim << std::endl; for(uint64_t i = 0; i < dim; i++){ std::cout << "[main] - |Psi_" << i << "> = " << state << std::endl; state.increment_NoU1(start,end); }
Output:
[main] - dim = 8 [main] - |Psi_0> = |0;0;0;0;0> [main] - |Psi_1> = |0;1;0;0;0> [main] - |Psi_2> = |0;0;1;0;0> [main] - |Psi_3> = |0;1;1;0;0> [main] - |Psi_4> = |0;0;0;1;0> [main] - |Psi_5> = |0;1;0;1;0> [main] - |Psi_6> = |0;0;1;1;0> [main] - |Psi_7> = |0;1;1;1;0>
-
int32_t danceq::internal::State::set_state_from_index_NoU1(const uint64_t index, const uint64_t start = 0, const uint64_t end = MaxSites)
Sets a State defined by an index without number conservation.
The state refers to the index with integer counting in the range start to end:
\[\textbf{index} = \sum_{i=\textbf{start}}^{\textbf{end}-1} \quad \sigma_i \cdot\textbf{Q}^{i-\textbf{start}}\]The inverse function is get_index_NoU1.
- Parameters:
index – Index to be set
start – Start of range
end – End of range
- Returns:
error_code
-
uint64_t danceq::internal::State::get_index_NoU1(const uint64_t start = 0, const uint64_t end = MaxSites) const
Retrieves an index from the State.
The index is obtained by the integer counting in the range start to end:
\[\textbf{index} = \sum_{i=\textbf{start}}^{\textbf{end}-1} \quad \sigma_i \cdot\textbf{Q}^{i-start}\]The inverse function is set_state_from_index_NoU1.
- Parameters:
start – Start of range
end – End of range
- Returns:
index
-
int32_t danceq::internal::State::increment_NoU1(const uint64_t start = 0, const uint64_t end = MaxSites, bool *overflow = nullptr)
Incrementing the State without number conservation.
The state is set to its increment defined by integer counting in the range start to end. The function is equivalent to (but more efficient):
state.set_state_from_index_NoU1(get_index_NoU1(start, end) + 1, start, end);
If overflow is given, it is set to
true
if the state jumps from its maximal index, \(Q^{\textbf{end}-\textbf{start}}-1\), to the minimal index, \(0\).- Parameters:
start – Start of range
end – End of range
overflow – Pointer to register overflow
- Returns:
error_code
-
int32_t danceq::internal::State::decrement_NoU1(const uint64_t start = 0, const uint64_t end = MaxSites, bool *underflow = nullptr)
Decrementing the State without number conservation.
The state is set to its decrement defined by integer counting in the range start to end. The function is equivalent to (but more efficient):
state.set_state_from_index_NoU1(get_index_NoU1(start, end) - 1, start, end);
If underflow is given, it is set to
true
if the state jumps from its minimal index, \(0\), to the maximal index, \(Q^{\textbf{end}-\textbf{start}}-1\).- Parameters:
start – Start of range
end – End of range
underflow – Pointer to register underflow
- Returns:
error_code
-
static uint64_t danceq::internal::State::get_dim_NoU1(const uint64_t length = MaxSites)
Returns the dimension for a given length without number conservation.
Simply returns \(Q^{\textbf{length}}\).
Note
The limit is determined by the upper bound of uint64_t.
- Parameters:
length – Length of the range
- Returns:
Dimension
Inhomogeneous Hilbert space dimensions
-
int32_t danceq::internal::State::set_state_from_index_NoU1_IHQ(const uint64_t index, const std::vector<uint64_t> &Q_list, const uint64_t start = 0)
Sets a State defined by an index without number conservation and inhomogeneously distributed local Hilbert space dimensions.
The state refers to the index with integer counting in the range start to start+Q_list.size():
\[\textbf{index} = \sum_{i=\textbf{start}}^{\textbf{end}-1} \quad \sigma_i \cdot\textbf{Q_list[i-start]}^{i-\textbf{start}}\]The inverse function is get_index_NoU1_IHQ. All entries in Q_list have to be within 1 and Q.
- Parameters:
index – Index to be set
Q_list – List of local Hilbert space dimensions
start – Start of range
- Returns:
error_code
-
uint64_t danceq::internal::State::get_index_NoU1_IHQ(const std::vector<uint64_t> &Q_list, const uint64_t start = 0) const
Retrieves an index from the State for with inhomogeneously distributed local Hilbert space dimensions.
The index is obtained by the integer counting in the range start to Q_list.size():
\[\textbf{index} = \sum_{i=\textbf{start}}^{\textbf{start}+\textbf{Q_list.size()}-1} \quad \sigma_i \cdot\textbf{Q_list[i]}^{i-start}\]The inverse function is set_state_from_index_NoU1_IHQ. All entries in Q_list have to be within 1 and Q.
- Parameters:
Q_list – List of local Hilbert space dimensions
start – Start of range
- Returns:
index
-
static uint64_t danceq::internal::State::get_dim_NoU1_IHQ(const std::vector<uint64_t> &Q_list)
Returns the dimension with inhomogeneously distributed local Hilbert space dimensions.
Simply returns
\[\textbf{dim} = \prod_{i=0}^{\textbf{Q_list.size()}-1} \textbf{Q_list[i]}\,.\]Note
The limit is determined by the upper bound of uint64_t.
- Parameters:
Q_list – List of local Hilbert space dimensions
- Returns:
Dimension