circus/gate/phase.rs
1use super::Gate;
2use crate::{State, PW};
3
4pub struct PhaseGate {
5 pub target: usize,
6}
7
8impl Gate for PhaseGate {
9 fn apply(&self, state: &mut State) {
10 let b5 = self.target >> 5;
11 let pw = PW[self.target & 31];
12
13 for i in 0..2 * state.n {
14 if state.x[i][b5] & pw > 0 && state.z[i][b5] & pw > 0 {
15 state.r[i] = (state.r[i] + 2) % 4;
16 }
17 state.z[i][b5] ^= state.x[i][b5] & pw;
18 }
19 }
20}