[−][src]Function q1tsim::gates::bit_permutation
pub fn bit_permutation(nr_bits: usize, affected_bits: &[usize]) -> Permutation
Reorder bits.
When applying multi-bit gates, the rows in the state are shuffled such that:
- The first half of the rows correspond to components with the first affected bit being 0, the second half to those with this bit being 1.
- Within each of these two blocks, the first half corresponds to components with the second bit 0, the second half to those with the second bit 1.
- And so on, for each affected bit.
This function returns a permutation matrix P
, such that the matrix
P (G ⊗ I ⊗ ... ⊗ I) P
T
describes the effect of operating with a
gate G
on bits affected_bits
in a nr_bits
-sized system.