State Handling

The operator provides direct access to the basis states. The functions do not depend on the template parameter T, Basis clas or State class.

std::vector<std::pair<ScalarType, uint64_t>> danceq::internal::Operator::apply(const state_class &state, const bool unique_output = false) const

Applies the operator to a single state.

Creates all elements with coefficients that are obtained when the operator is applied to the input State state. The first entry in the std::pair refers to the coefficients and the second entry refers to the index within the used basis. The state can be retrieved using get_state(index), see the example below. The returned elements are ordered and double entries as well as zeros are removed.

auto elements = H.apply(psi);
std::cout << "H|psi> = ";
for (auto & element : Hpsi){
    State state__ = H.get_state(element.second); // retrieving state from basis index
    std::cout << "+ " << Helement.first << " " << state__.get_string(0UL, L) << " (Basis index: " << element.second << ")" << std::endl;
}
std::cout << std::endl;

If unique_output is true, double elements of the return std::vector are merged.

Parameters:
  • state – State of interests

  • unique_output – Boolean to control the unique output

Returns:

All created coefficients and the corresponding index

uint64_t danceq::internal::Operator::get_index(const state_class &state) const

Returns the index of a state.

If T refers to a BasisU1 the index is obtained using basisptr and get_index(…). If T refers to State Class the index is obtained using get_index_NoU1(0UL ,L).

Parameters:

state – State of interests

Returns:

Index

state_class danceq::internal::Operator::get_state(const uint64_t index) const

Returns the state for a given index.

If T refers to a BasisU1 the index is obtained using basisptr and set_state(…). If T refers to State Class the index is obtained using set_state_from_index_NoU1(index, 0UL, L).

Parameters:

index – Index of interests

Returns:

state

int32_t danceq::internal::Operator::increment_state(state_class &state, bool *overflow = nullptr) const

Increments the state.

If T refers to a BasisU1 the index is obtained using basisptr and increment(state). If T refers to State Class the index is obtained using increment_NoU1(0UL,L)(index, 0UL, L). If the pointer overflow is set this results in setting it to true otherwise it is false.

Parameters:
  • state – State to be incremented

  • overflow – Pointer for overflow detection

Returns:

error_code