(self, **options)
Decompose the controlled gate into CNOT and single qubits gates.
Decompose the controlled gate into CNOT and single qubits gates.
Decompose the controlled gate into CNOT and single qubits gates .
def decompose(self, **options):
        """Decompose the controlled gate into CNOT and single qubits gates."""
        if len(self.controls) == 1:
            c = self.controls[0]
            t = self.gate.targets[0]
            if isinstance(self.gate, YGate):
                g1 = PhaseGate(t)
                g2 = CNotGate(c, t)
                g3 = PhaseGate(t)
                g4 = ZGate(t)
                return g1*g2*g3*g4
            if isinstance(self.gate, ZGate):
                g1 = HadamardGate(t)
                g2 = CNotGate(c, t)
                g3 = HadamardGate(t)
                return g1*g2*g3
        else:
            return self
def decompose ( self , * * options ) : if len ( self . controls ) == 1 : c = self . controls [ 0 ] t = self . gate . targets [ 0 ] if isinstance ( self . gate , YGate ) : g1 = PhaseGate ( t ) g2 = CNotGate ( c , t ) g3 = PhaseGate ( t ) g4 = ZGate ( t ) return g1 * g2 * g3 * g4 if isinstance ( self . gate , ZGate ) : g1 = HadamardGate ( t ) g2 = CNotGate ( c , t ) g3 = HadamardGate ( t ) return g1 * g2 * g3 else : return self