Autodocs

template<uint64_t MaxSites = 128, uint64_t Q = 2, class IntType = uint64_t, uint64_t Nbits = get_Nbits_from_Q(Q), uint64_t NInt = (((8UL * sizeof(IntType)) / Nbits) + MaxSites - 1) / ((8UL * sizeof(IntType)) / Nbits)>
class State

Primitive class to work with a system containing multiple qudits.

Template parameters

  • uint64_t MaxSites: Maximal number of sites that can be stored.

    Default: 128

  • uint64_t Q: Local Hilbert space dimension of a single qudit: \(\vert\sigma_i\rangle = \vert 0 \rangle, \dots, \vert Q-1\rangle\).

    Default: 2

  • class IntType: Primitive integer type to bitwise encode qudits.

    Default: uint64_t

  • uint64_t Nbits: Number of bits to represent a single qudit, it has to fulfill \(2^{\textbf{Nbits}} \geq Q\).

    Default: get_Nbits_from_Q(Q)

  • uint64_t NInt: Number of primitive integers stored in an array to store MaxSites, it has to fulfill \(\textbf{NInt}\cdot\texttt{sizeof}(\textbf{IntType})/\textbf{Nbits}\geq \textbf{MaxSites}\).

    Default: \(\frac{((8\texttt{UL}\cdot\texttt{sizeof}(\textbf{IntType}))/\textbf{Nbits}) + \textbf{MaxSites} - 1}{(8UL*\texttt{sizeof}(\textbf{IntType}))/\textbf{Nbits}}\)

Things to know

  • There is a single data field defined by the template parameters: std::array<IntType,NInt>

  • Many functions are defined for an interval between start and end.

  • The State class provides two enumeration procedures with a complete set of functions including increment, decrement, get_index, and set_state_from_index. The enumeration refers to the integer counting with basis \(Q\):

    \[\textbf{index} = \sum_{i=\textbf{start}}^{\textbf{end}-1} \quad \sigma_i \cdot\textbf{Q}^{i-\textbf{start}}\]

    One set of functions conserves the total particle number:

    \[\textbf{n} = \sum_{i=\textbf{start}}^{\textbf{end}-1} \sigma_i\]

    More details can be found in Functions. The functions are less efficient than the BasisU1.

  • The State class allows different comparisons between instances: lesser, greater, and equal. These functions are either defined on the integer level and on the qudit level \(\vert \sigma_i\rangle\).

  • 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
    

Public Types

using integer_type = IntType

Defines the IntType.

using data_type = std::array<IntType, NInt>

Defines the data array.

using state_class = State<MaxSites, Q, IntType, Nbits, NInt>

State class.

State class can be retrieved from the itself. This is required by std::variant for the BasisU1.

Public Functions

State(void)

Default constructor.

Initializes a State instance where all sites are set to zero, \(\vert\sigma_i\rangle = \vert 0 \rangle\) for all \(i\).

State(const std::array<IntType, NInt> array_input, const bool check_data = true)

Constructor with std::array.

Initializes a State instance by setting data to the array_input.

Parameters:
  • array_input – Array input

  • check_data – Boolean to check input data (Default: true)

State(const State<MaxSites, Q, IntType, Nbits, NInt> &state_input)

Copy constructor.

Initializes a State instance from state_input.

Parameters:

state_input – State input

State(const uint64_t index, const uint64_t start, const uint64_t end)

Setting the State with integer counting.

Initializes a State instance such that the index is generated by interger counting of basis \(Q\) in the range start to end:

\[\textbf{index} = \sum_{i=\textbf{start}}^{\textbf{end}-1} \quad \sigma_i \cdot\textbf{Q}^{i-\textbf{start}} \, .\]

More information can be found here.

Parameters:
  • index – Target index

  • start – Start of range

  • end – End of range

State(const uint64_t index, const IntType particle_number, const uint64_t start, const uint64_t end)

Setting a State with integer counting given the total particle number.

Initializes a State instance with a given particle number, particle_number, on sites start to end-1. index refers to the number of states with the same particle_number that encode a smaller integer obtained from the interger counting to the basis \(Q\).

\[\textbf{particle_number} = \sum_{i=\textbf{start}}^{\textbf{end}-1} \quad \sigma_i \,.\]

More information can be found here.

Parameters:
  • index – Target index

  • particle_number – Total particle number

  • start – Start of range

  • end – End of range

State(const std::vector<IntType> &state_vector)

Constructor from std::vector<IntType>.

Initializes a State instance from an input vector: \(\vert \sigma_i\rangle = \textbf{state_vector}[i]\).

Parameters:

state_vector – State vector

State(const std::initializer_list<IntType> &state_list)

Constructor from std::initializer_list<IntType>.

Initializes a State instance from a braced initializer list of the site states: \(\vert \sigma_i\rangle = \textbf{state_list}[i]\). Usage:

State s {0,1,1,0,1}; // creates state |01101>.

Parameters:

state_list – braced initializer list

State(const std::vector<IntType> &state_vector, const uint64_t start)

Constructor with std::vector<IntType> with an offset.

Initializes a State instance from an input vector with an offset start: \(\vert \sigma_{i+\textbf{start}}\rangle = \textbf{state_vector}[i]\).

Parameters:
  • state_vector – State vector

  • start – Offset to initialize the state

State(const std::vector<IntType> &state_vector, const std::vector<uint64_t> &index_vector)

Constructor with std::vector<IntType> with an additional index vector.

Initializes a State instance from an input vector and an indexing vector: \(\vert \sigma_{i+\textbf{index_vector}[i]}\rangle =\textbf{state_vector}[i]\).

Parameters:
  • state_vector – State vector

  • index_vector – Index vector

uint64_t get_MaxSites(void) const

Returns MaxSites.

Returns:

MaxSites

uint64_t get_Q(void) const

Returns Q.

Returns:

Q

uint64_t get_Nbits(void) const

Returns Nbits.

Returns:

Nbits

uint64_t get_NInt(void) const

Returns NInt.

Returns:

NInt

uint64_t get_sizeof_IntType(void) const

Returns size of IntType.

Returns:

size of IntType

std::array<IntType, NInt> get_data(void) const

Returns data.

Returns:

data

int32_t info(void) const

Prints information about the State.

Prints the following information: MaxSites, Q, sizeof(IntType), Nbits, NInt, dbug_level, and states_per_IntType.

Returns:

error_code

std::string get_string(const uint64_t start = 0, const uint64_t end = MaxSites) const

Generates an output string.

Returns an output string with states on sites start to end-1:

\[\vert \sigma_{\textbf{start}};\sigma_{\textbf{start}+1};\dots;\sigma_{\textbf{end}-1}\rangle\]

Parameters:
  • start – Start of range

  • end – End of range

Returns:

Output string

int32_t get_string_reference(std::string *output, const uint64_t start = 0, const uint64_t end = MaxSites) const

Generates an output string.

Overwrites the output string with states on sites start to end-1:

\[\vert \sigma_{\textbf{start}};\sigma_{\textbf{start}+1};\dots;\sigma_{\textbf{end}-1}\rangle\]

Parameters:
  • output – String pointer to store the output

  • start – Start of range

  • end – End of range

Returns:

error_code

std::string get_string(const std::vector<uint64_t> &pos) const

Generates an output string.

Returns an output string with states given by pos:

\[\vert \sigma_{\textbf{pos}[0]};\sigma_{\textbf{pos}[0]};\dots;\sigma_{\textbf{pos}[\textbf{pos}.\texttt{size}()-1]}\rangle\]

Parameters:

pos – Vector containing the sites

Returns:

error_code

int32_t get_string_reference(std::string *output, const std::vector<uint64_t> &pos) const

Generates an output string.

Overwrites the output string with states given by pos:

\[\vert \sigma_{\textbf{pos}[0]};\sigma_{\textbf{pos}[0]};\dots;\sigma_{\textbf{pos}[\textbf{pos}.\texttt{size}()-1]}\rangle\]

Parameters:
  • output – String pointer to store the output

  • pos – Vector containing the sites

Returns:

error_code

int32_t print(const uint64_t start = 0, const uint64_t end = MaxSites) const

Prints the State.

Prints State on within start and end-1.

Parameters:
  • start – Start of range

  • end – End of range

Returns:

error_code

int32_t toggle(const uint64_t site_index)

Toggles a specific qudit.

Toggles the local state at site site_index:

\[\vert \sigma_{\textbf{site_index}} \rangle \rightarrow \vert Q - 1 - \sigma_{\textbf{site_index}}\rangle\]

Parameters:

site_index – Site to toggle

Returns:

error_code

int32_t set_state(const IntType local_state, const uint64_t site_index)

Sets a specific site.

Sets the site to \(\vert \textbf{local_state}\rangle\).

Parameters:
  • local_state – New local state

  • site_index – Site to modify

Returns:

error_code

int32_t set_range(const IntType local_state, const uint64_t start = 0, const uint64_t end = MaxSites)

Sets a whole range.

Sets all sites from start to end-1 to \(\vert \textbf{local_state}\rangle\).

Parameters:
  • local_state – New local state

  • start – Start of range

  • end – End of range

Returns:

error_code

State<MaxSites, Q, IntType, Nbits, NInt> operator>>(const uint64_t index)

Shifts all states by index to the right.

Shifts all local qudits \(\vert \sigma_i\rangle\) by index to the right:

\[\vert \sigma_i\rangle \rightarrow \vert \sigma_{i+\textbf{index}}\rangle\]

States that are coming in from the left are set to \(\vert 0 \rangle\).

Parameters:

index – Index to shift

Returns:

Shifted state

State<MaxSites, Q, IntType, Nbits, NInt> operator<<(const uint64_t index)

Shifts all states by index to the left.

Shifts all local qudits \(\vert \sigma_i\rangle\) by index to the left:

\[\vert \sigma_i\rangle \rightarrow \vert \sigma_{i-\textbf{index}}\rangle\]

States that are coming in from the right are set to \(\vert 0 \rangle\).

Parameters:

index – Index to shift

Returns:

Shifted state

State<MaxSites, Q, IntType, Nbits, NInt> operator&(const State<MaxSites, Q, IntType, Nbits, NInt> &state_input) const

Bitwise operator &.

Applies the bitwise operator & to all integers in data.

Parameters:

state_input – Input state

Returns:

Output state

State<MaxSites, Q, IntType, Nbits, NInt> operator|(const State<MaxSites, Q, IntType, Nbits, NInt> &state_input) const

Bitwise operator |.

Applies the bitwise operator | to all integers in data.

Parameters:

state_input – Input state

Returns:

Output state

State<MaxSites, Q, IntType, Nbits, NInt> operator~() const

Bitwise operator ~.

Applies the bitwise operator ~ to all integers in data.

Returns:

Output state

const IntType operator[](uint64_t site_index) const

Reads the local state at a given site.

Returns state at site site_index, \(\vert \sigma_{\textbf{site_index}} \rangle\).

IntType local_state = state[site_index];

Warning

Only the return option of the operator [] is defined. Use the function set_state(…) to modify a specific site.

Parameters:

site_index – Site to read

Returns:

Local site

int32_t get_state(IntType *state_output, uint64_t site_index) const

Reads the local state at a given sites.

Returns state at site site_index, \(\vert \sigma_i \rangle\).

Parameters:
  • state_output – IntType pointer for local state

  • site_index – Site to read

Returns:

Shifted state

State<MaxSites, Q, IntType, Nbits, NInt> get_range(uint64_t start = 0, uint64_t end = MaxSites) const

Returns a truncated State within a range.

Returns an instance of State truncated to start to end-1.

Parameters:
  • start – Start of range

  • end – End of range

Returns:

Truncated state

int32_t get_range(State<MaxSites, Q, IntType, Nbits, NInt> *output, uint64_t start = 0, uint64_t end = MaxSites) const

Retrieves a range of local states and writes them to a new State instance.

Writes an instance of State truncated to start to end-1 to output.

Parameters:
  • output – Instance of State to store the truncated data

  • start – Start of range

  • end – End of range

Returns:

error_code

int32_t get_range(IntType *output, uint64_t start = 0, uint64_t end = 1) const

Retrieves a range of local states and writes them to a single integer.

Writes the data defined on start to end-1 to output which is an Integer of type IntType.

Note

This is only possible if \((\textbf{end}-\textbf{start})\cdot \textbf{Nbits} > \texttt{sizeof}(\textbf{IntType})\cdot 8\texttt{UL}\)

Parameters:
  • output – Integer for bitwise data

  • start – Start of range

  • end – End of range

Returns:

error_code

int32_t get_range(std::vector<IntType> *output, uint64_t start = 0, uint64_t end = MaxSites) const

Retrieves a range of local states and writes them to a vector.

Writes the data defined on start to end-1 to output which is std::vector<IntType> .

Parameters:
  • output – Vector to write the local states

  • start – Start of range

  • end – End of range

Returns:

error_code

bool operator>(const State<MaxSites, Q, IntType, Nbits, NInt> &state_input) const

Compares two State instances.

Note

The comparison is done on the level of the integers stored in data and not on the qudit level.

Parameters:

state_input – State to be compared

Returns:

true if left side is greater, otherwise false

bool operator<(const State<MaxSites, Q, IntType, Nbits, NInt> &state_input) const

Compares two State instances.

Note

The comparison is done on the level of the integers stored in data and not on the qudit level.

Parameters:

state_input – State to be compared

Returns:

true if left side is lesser, otherwise false

bool operator==(const State<MaxSites, Q, IntType, Nbits, NInt> &state_input) const

Compares two State instances.

Note

The comparison is done on the level of the integers stored in data and not on the qudit level.

Parameters:

state_input – State to be compared

Returns:

true if both instances are equal, otherwise false

bool greater_state_level(const State<MaxSites, Q, IntType, Nbits, NInt> &state_input, uint64_t start = 0, uint64_t end = MaxSites) const

Compares two State instances on the qudit level.

Note

The comparison is done on the qudit level and not with the integers stored in data.

Parameters:
  • state_input – State to be compared

  • start – Start of range for comparison

  • end – End of range for comparison

Returns:

true if this->State is greater, otherwise false

bool lesser_state_level(const State<MaxSites, Q, IntType, Nbits, NInt> &state_input, uint64_t start = 0, uint64_t end = MaxSites) const

Compares two State instances on the qudit level.

Note

The comparison is done on the qudit level and not with the integers stored in data.

Parameters:
  • state_input – State to be compared

  • start – Start of range for comparison

  • end – End of range for comparison

Returns:

true if this->State is lesser, otherwise false

bool equal_state_level(const State<MaxSites, Q, IntType, Nbits, NInt> &state_input, uint64_t start = 0, uint64_t end = MaxSites) const

Compares two State instances on the qudit level.

Note

The comparison is done on the qudit level and not with the integers stored in data.

Parameters:
  • state_input – State to be compared

  • start – Start of range for comparison

  • end – End of range for comparison

Returns:

true if both states are equal, otherwise false

int32_t 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

int32_t 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 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

int32_t get_index_NoU1_IHQ(uint64_t *output, 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:
  • output – Pointer for output

  • Q_list – List of local Hilbert space dimensions

  • start – Start of range

Returns:

error_code

uint64_t 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 get_index_NoU1(uint64_t *output, const uint64_t start = 0, const uint64_t end = MaxSites) const

Retrieves 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}\]

This is the inverse function to set_state_from_index_NoU1.

Parameters:
  • output – Pointer for output

  • start – Start of range

  • end – End of range

Returns:

error_code

int32_t 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 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

State<MaxSites, Q, IntType, Nbits, NInt> &operator++()

Incrementing the State without number conservation over the whole range.

The state is set to its increment defined by integer counting in the range \(\textbf{start}=0\) to \(\textbf{end}=\textbf{MaxSites}\). The function calls increment_NoU1(0, MaxSites).

State<MaxSites, Q, IntType, Nbits, NInt> &operator--()

Decrementing the State without number conservation over the whole range.

The state is set to its decrement defined by integer counting in the range \(\textbf{start}=0\) to \(\textbf{end}=\textbf{MaxSites}\). The function calls decrement_NoU1(0, MaxSites).

uint64_t get_particle_number(const uint64_t start = 0, const uint64_t end = MaxSites) const

Returns the total particle number within a given range.

The particle number within the range start and end is defined by

\[\textbf{particle_number} = \sum_{i=\textbf{start}}^{\textbf{end}-1} \sigma_i\,.\]

Parameters:
  • start – Start of range

  • end – End of range

Returns:

Particle number

int32_t get_particle_number_reference(IntType *output, const uint64_t start = 0, const uint64_t end = MaxSites) const

Returns the total particle number within a given range.

The particle number within the range start and end is defined by

\[\textbf{particle_number} = \sum_{i=\textbf{start}}^{\textbf{end}-1} \sigma_i\,.\]

Parameters:
  • output – Pointer for output

  • start – Start of range

  • end – End of range

Returns:

error_code

int32_t set_state_from_index_U1(const uint64_t index, const IntType num = -1, const uint64_t start = 0, const uint64_t end = MaxSites)

Sets a State defined by an index with number conservation.

The state refers to the index with number conservation in the range start to end. This is the inverse function of get_index_U1. The particle number can be set by num. Its default value is -1 which takes the current particle number, get_particle_number(start, end), as an input.

Parameters:
  • index – Index to be set

  • num – Particle number sector

  • start – Start of range

  • end – End of range

Returns:

error_code

uint64_t get_index_U1(const uint64_t start = 0, const uint64_t end = MaxSites) const

Retrieves index from the State.

The index is obtained by the integer counting in the range start to end with additional number conservation. This is the inverse function of set_state_from_index_U1.

Parameters:
  • start – Start of range

  • end – End of range

Returns:

error_code

int32_t get_index_U1(uint64_t *output, const uint64_t start = 0, const uint64_t end = MaxSites) const

Retrieves index from the State.

The index is obtained by the integer counting in the range start to end with additional number conservation. This is the inverse function of set_state_from_index_U1.

Parameters:
  • output – Pointer for the output

  • start – Start of range

  • end – End of range

Returns:

error_code

int32_t increment_U1(uint64_t start = 0, uint64_t end = MaxSites, bool *overflow = nullptr)

Incrementing the State with number conservation.

The state is set to its increment defined by integer counting in the range start to end and the current particle number.

If overflow is given, it is set to true if the state jumps from its maximal index to the minimal index.

Parameters:
  • start – Start of range

  • end – End of range

  • overflow – Pointer to register overflow

Returns:

error_code

int32_t decrement_U1(uint64_t start = 0, uint64_t end = MaxSites, bool *underflow = nullptr)

Decrementing the State with number conservation.

The state is set to its decrement defined by integer counting in the range start to end and the current particle number.

If underflow is given, it is set to true if the state jumps from its minimal index to the maximal index.

Parameters:
  • start – Start of range

  • end – End of range

  • underflow – Pointer to register underflow

Returns:

error_code

int32_t set_minimal(const IntType number, const uint64_t start = 0, const uint64_t end = MaxSites)

Sets the minimal State for a given number sector.

Parameters:
  • number – Number of the sector

  • start – Start of range

  • end – End of range

Returns:

error_code

int32_t set_maximal(IntType n, uint64_t start = 0, uint64_t end = MaxSites)

Sets the maximal State for a given number sector.

Parameters:
  • n – Number of the sector

  • start – Start of range

  • end – End of range

Returns:

error_code

uint64_t hash(void) const

Hash function.

The function is used by struct HashFunction that allows the usage of std::unordered_set and std::unordered_map:

Returns:

hash

int32_t check_data(void)

Evaluation data of state.

The functions checks if the state is valid.

Returns:

0 (valid state) or 1 (non-valid state)

Public Static Functions

static uint64_t 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

static int32_t get_dim_NoU1(uint64_t *dim, uint64_t length)

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:
  • dim – Pointer for output

  • length – Length of the range

Returns:

error_code

static uint64_t 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

static int32_t get_dim_NoU1_IHQ(uint64_t *dim, 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:
  • dim – Pointer for output

  • Q_list – List of local Hilbert space dimensions

Returns:

error_code

static uint64_t get_dim_U1(const uint64_t number, const uint64_t length = MaxSites, const uint64_t Q_ = Q)

Returns the dimension of a specific sector with number conservation.

The dimension of a particle number sector for a system of size length and a local Hilbert space dimension Q__ with a total of number excitations is obtained by the Eq. (2).

Warning

The method produces overflow errors due the alternating sign in the equation for large values.

Parameters:
  • number – Number sector

  • length – Size of the system

  • Q_ – Local Hilbert space dimension

Returns:

Dimension

static int32_t get_dim_U1(uint64_t *dimension, const uint64_t number, const uint64_t length = MaxSites, const uint64_t Q__ = Q, bool print_warning = true)

Returns the total dimension of a specific sector with number conservation.

The dimension of a particle sector of size length and a local Hilbert space dimension Q__ with number excitations is obtained by the Eq. (2) from the paper.

Note

The method produces overflow errors due the alternating sign in the equation for large dimensions. If print_warning is true warnings are printed if an overflow is detected.

Parameters:
  • dimension – Pointer for the output

  • number – Number sector

  • length – Size of the system

  • Q__ – Local Hilbert space dimension

  • print_warning – Prints the warning if true

Returns:

error_code

Public Static Attributes

static const bool is_State = true

Needed for specification.

Private Functions

int32_t get_MaxSites(uint64_t *output) const

Returns MaxSites.

Parameters:

output – Pointer for output

Returns:

error_code

int32_t get_Q(uint64_t *output) const

Returns Q.

Parameters:

output – Pointer for output

Returns:

error_code

int32_t get_Nbits(uint64_t *output) const

Returns Nbits.

Parameters:

output – Pointer for output

Returns:

error_code

int32_t get_NInt(uint64_t *output) const

Returns NInt.

Parameters:

output – Pointer for output

Returns:

error_code

int32_t get_sizeof_IntType(uint64_t *output) const

Returns size of IntType.

Parameters:

output – Pointer for output

Returns:

error_code

int32_t get_data(std::array<IntType, NInt> *output) const

Returns data.

Parameters:

output – Pointer for output

Returns:

error_code

Private Members

std::array<IntType, NInt> data

Data member for bitwise storage.

Each \(\vert\sigma_i\rangle\) is bitwise stored using an array of the primitive integer type IntType. A local site is encoded in Nbits bits. Each integer encodes \(M=\) ( sizeof ( IntType ) \(\cdot 8\) ) / Nbits qudits.

Memory alignment:

Integers

Block \(M-1\)

Block 1

Block 0

data[0]

\(\vert\sigma_{M-1}\rangle\)

\(\vert\sigma_1\rangle\)

\(\vert\sigma_0\rangle\)

data[1]

\(\vert\sigma_{2M-1}\rangle\)

\(\vert\sigma_{M+1}\rangle\)

\(\vert\sigma_M\rangle\)

data[NInt-1]

\(\vert\sigma_{\textbf{MaxSites}-1}\rangle\)

\(\vert\sigma_0\rangle\)

struct HashFunction

Struct for the hash function.

The struct is used for std::unordered_set and std::unordered_map.

std::unordered_set<State, typename State::HashFunction> myuSet;
std::unordered_map<State, uint64_t, typename State::HashFunction> myuMap;

Public Functions

uint64_t operator()(const State<MaxSites, Q, IntType, Nbits, NInt> &input) const

Overloaded operator calling the hash function.

Calls hash().

Parameters:

input – State for input

Returns:

hash

struct template_struct

Struct to use the template parameters.

The struct can be used to access the template parameters without an instance of the State class. This can also be used for constexpr.

uint64_t Q = State::template_struct::template_Q;

Public Static Attributes

static const uint64_t template_MaxSites = MaxSites

Template MaxSites.

static const uint64_t template_Q = Q

Template Q.

static const uint64_t template_Nbits = Nbits

Template Nbits.

static const uint64_t template_NInt = NInt

Template NInt.

static const uint64_t sizeof_IntType = static_cast<uint64_t>(sizeof(IntType))

Size of IntType.

Additional function

constexpr uint64_t danceq::internal::get_Nbits_from_Q(const uint64_t Q)

Calculating the minimal number of bits to encode Q states,.

Function returns the minimal number of bits needed to represent \(Q\) states:

\[2^{\textbf{Nbits}} \geq Q\]

Parameters:

Q – Local Hilbert space dimension

Returns:

Nbits