qml.order_states¶
- order_states(basis_states)[source]¶
This function maps a given list of \(m\) computational basis states to the first \(m\) computational basis states, except for input states that are among the first \(m\) computational basis states, which are mapped to themselves.
- Parameters:
basis_states (list[list[int]]) – sequence of \(m\) basis states to be mapped. Each state is a sequence of 0s and 1s.
- Returns:
dictionary mapping basis states to the first \(m\) basis states, except for fixed points (states in the input that already were among the first \(m\) basis states).
- Return type:
dict[tuple[int], tuple[int]]
Example
For instance, a given list of \([s_0, s_1, ..., s_m]\) where \(s\) is a basis state of length \(4\) will be mapped as \(\{s_0: |0000\rangle, s_1: |0001\rangle, s_2: |0010\rangle, \dots\}\).
>>> basis_states = [[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 0, 1]] >>> order_states(basis_states) {(1, 1, 0, 0): (0, 0, 0, 0), (1, 0, 1, 0): (0, 0, 0, 1), (0, 1, 0, 1): (0, 0, 1, 0), (1, 0, 0, 1): (0, 0, 1, 1)}
If a state in
basis_states
is one of the first \(m\) basis states, this state will be mapped to itself, i.e. it will be a fixed point of the mapping.>>> basis_states = [[1, 1, 0, 0], [0, 1, 0, 1], [0, 0, 0, 1], [1, 0, 0, 1]] >>> order_states(basis_states) {(0, 0, 0, 1): (0, 0, 0, 1), (1, 1, 0, 0): (0, 0, 0, 0), (0, 1, 0, 1): (0, 0, 1, 0), (1, 0, 0, 1): (0, 0, 1, 1)}