(self)
return circuit
Decomposes QFT into elementary gates.
Decomposes QFT into elementary gates.
Decomposes QFT into elementary gates .
def decompose(self):
        """Decomposes QFT into elementary gates."""
        start = self.label[0]
        finish = self.label[1]
        circuit = 1
        for level in reversed(range(start, finish)):
            circuit = HadamardGate(level)*circuit
            for i in range(level - start):
                circuit = CGate(level - i - 1, RkGate(level, i + 2))*circuit
        for i in range((finish - start)//2):
            circuit = SwapGate(i + start, finish - i - 1)*circuit
        return circuit
def decompose ( self ) : start = self . label [ 0 ] finish = self . label [ 1 ] circuit = 1 for level in reversed ( range ( start , finish ) ) : circuit = HadamardGate ( level ) * circuit for i in range ( level - start ) : circuit = CGate ( level - i - 1 , RkGate ( level , i + 2 ) ) * circuit for i in range ( ( finish - start ) // 2 ) : circuit = SwapGate ( i + start , finish - i - 1 ) * circuit return circuit