def qft_steps(N=1, swapping=True): """ Quantum Fourier Transform operator on N qubits returning the individual steps as unitary matrices operating from left to right. Parameters ---------- N: int Number of qubits. swap: boolean Flag indicating sequence of swap gates to be applied at the end or not. Returns ------- U_step_list: list of qobj List of Hadamard and controlled rotation gates implementing QFT. """ if N < 1: raise ValueError("Minimum value of N can be 1") U_step_list = [] if N == 1: U_step_list.append(snot()) else: for i in range(N): for j in range(i): U_step_list.append( cphase(np.pi / (2**(i - j)), N, control=i, target=j)) U_step_list.append(snot(N, i)) if swapping: for i in range(N // 2): U_step_list.append(swap(N, [N - i - 1, i])) return U_step_list
def test_qpt_snot(): "quantum process tomography for snot gate" U_psi = snot() U_rho = spre(U_psi) * spost(U_psi.dag()) N = 1 op_basis = [[qeye(2), sigmax(), 1j * sigmay(), sigmaz()] for i in range(N)] # op_label = [["i", "x", "y", "z"] for i in range(N)] chi1 = qpt(U_rho, op_basis) chi2 = np.zeros((2**(2 * N), 2**(2 * N)), dtype=complex) chi2[1, 1] = chi2[1, 3] = chi2[3, 1] = chi2[3, 3] = 0.5 assert_(la.norm(chi2 - chi1) < 1e-8)
def ch(): return controlled_gate(snot())