fn build_cx(&mut self, c: Wire, t: Wire) -> Result<[Wire; 2], BuildError> {
let pi = pi_mul_f64(self, 1.0);
let pi_2 = pi_mul_f64(self, 0.5);
let pi_minus_2 = pi_mul_f64(self, -0.5);
let t = self.add_phased_x(t, pi_minus_2, pi_2)?; // should be pi_2,pi_2
let [c, t] = self.add_zz_max(c, t)?;
let c = self.add_rz(c, pi_minus_2)?; // should be pi_2
let t = self.add_phased_x(t, pi_2, pi)?; // should be pi/2 0. I think this together with the previous op are equivalent to the other implementation though
let t = self.add_rz(t, pi_minus_2)?;
Ok([c, t])
}
Correct lowering:
def cx(self, control: int, target: int):
"""
Apply a controlled-X gate to the given qubits.
"""
self.rxy(target, pi/2, pi/2);
self.rzz(control, target, pi/2);
self.rz(control, pi/2);
self.rxy(target, pi/2, 0.);
self.rz(target, -pi/2);
Current lowering:
Correct lowering: