Skip to main content

State Range

Overview

  • State range methods can be used to produce objects that represent an ordered list of state objects, which can be iterated over.
  • Currently supported ranges include qbit_range and fbit_range.
warning

The qbit_range and fbit_range methods may get deprecated in favor of the method state_range(args..., options) in an upcoming update.

qbit_range

qbit_range is a function used to produce an object representing an ordered list of Qbit objects which can be iterated over.

Its main purpose is to provide a simple way of iterating over all possible qubit product state with support over a fixed number of sites LL.

Using qbit_range

A common use case is the need to iterate over all possible qubit product states defined on LL sites. This can be achieved using qbit_range as follows:

// A for loop over all qubit product states with support on two sites $(L = 2)$
for(product_state : qbit_range(2)) {
print([product_state, product_state.integer()])
}
// Returns [(1 + 0i)|00>, 0] [(1 + 0i)|10>, 1] [(1 + 0i)|01>, 2] [(1 + 0i)|11>, 3]

The order in which the states appear follows the established ordering convention specific to the target state type. In the example above, the qubit product states are iterated in the order corresponding to their integer representation, obtained by interpreting the qubit states (00 or 11) as the bits of a binary number.

fbit_range

  • fbit_range is a method used to produce an object representing an ordered list of Fbit objects which can be iterated over.

Using fbit_range

Similarly to qbit_range, the fbit_range function provides a simple way to iterate over all possible fermionic product states defined on a fixed number of sites LL. For example:

// A for loop over all fermionic product state with support on two sites
for(product_state : fbit_range(2)) {
print([product_state, product_state.integer()])
}
// Returns [(1 + 0i)|00>, 0] [(1 + 0i)|10>, 1] [(1 + 0i)|01>, 2] [(1 + 0i)|11>, 3]

Here the order is determined by interpreting the occupation numbers (00 or 11) as the binary expansion of an integer.

See Also

  • To check out more detailed documentation see fbit_range and qbit_range in the Library Reference.
  • Qbit: Introduction to the Qbit class and its properties.

Documentation Contributors

Pierre-Gabriel Rozon