-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy path05_Quantum_Fourier_Transform.py
More file actions
29 lines (22 loc) · 1.01 KB
/
05_Quantum_Fourier_Transform.py
File metadata and controls
29 lines (22 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'''
Quantum Fourier Transform (QFT)
The Fourier transform occurs in many different versions throughout classical computing,
in areas ranging from signal processing to data compression to complexity theory.
The quantum Fourier transform (QFT) is the quantum implementation of the discrete Fourier
transform over the amplitudes of a wave function. It is part of many quantum algorithms,
most notably Shor's factoring algorithm and quantum phase estimation.
Resource: https://quantum-computing.ibm.com/support/guides/quantum-algorithms-with-qiskit?page=5cbc5e2d74a4010049e1a2b0#qiskit-implementation
'''
import math
def qft(circuit, qr, n):
for j in range(n):
circuit.h(qr[j])
for k in range(j+1, n):
circuit.cu1(math.pi / float(2**(k-j)), qr[k], qr[j])
circuit.barrier()
def qft_dagger(circuit, q, n):
for j in range(n):
k = (n-1) - j
for m in range(k):
circuit.cu1(-math.pi/float(2**(k-m)), q[k], q[m])
circuit.h(q[k])