Quantum Fourier Transform (QFT)
The QFT
module enables the creation of circuit for $n$-qubit quantum Fourier transforms, and their inverses.
API
rqc.jl
QXZoo.QFT.apply_qft!
— Methodapply_qft!(cct::Circuit.Circ, qubit_indices::Vector)
Apply the quantum Fourier transform over the given qubit index range.
QXZoo.QFT.apply_qft!
— Methodapply_qft!(cct::Circuit.Circ)
Apply the quantum Fourier transform over the entire qubit register
QXZoo.QFT.apply_iqft!
— Methodapply_qft!(cct::Circuit.Circ, qubit_indices::Vector)
Apply the inverse quantum Fourier transform over the given qubit index range.
QXZoo.QFT.apply_iqft!
— Methodapply_iqft!(cct::Circuit.Circ)
Apply the inverse quantum Fourier transform over the entire qubit register
QXZoo.QFT.swap_idx
— Methodswap_idx(qubit_indices::Vector)
Return the indices of the qubits required to apply the swap operations as part of the transform.
Example
The following demonstrates the application of the QFT to a subset of qubits in the register, and the IQFT to the entire register.
using QXZoo
cct = QXZoo.Circuit.Circ(8)
QXZoo.QFT.apply_qft!(cct, collect(1:4))
QXZoo.QFT.apply_iqft!(cct)
println(cct)
for i in cct.circ_ops
println(i)
end
8 qubits with 52 gate-calls using 12 unique gates.
GateCall1(GateSymbol(:h, 0, false), 1)
GateCall2(GateSymbolP(:c_r_phase, 0, false, 1.5707963267948966), 1, 2, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, 0.7853981633974483), 1, 3, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, 0.39269908169872414), 1, 4, nothing)
GateCall1(GateSymbol(:h, 0, false), 2)
GateCall2(GateSymbolP(:c_r_phase, 0, false, 1.5707963267948966), 2, 3, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, 0.7853981633974483), 2, 4, nothing)
GateCall1(GateSymbol(:h, 0, false), 3)
GateCall2(GateSymbolP(:c_r_phase, 0, false, 1.5707963267948966), 3, 4, nothing)
GateCall1(GateSymbol(:h, 0, false), 4)
GateCall2(GateSymbol(:swap, 0, false), 1, 4, nothing)
GateCall2(GateSymbol(:swap, 0, false), 2, 3, nothing)
GateCall2(GateSymbol(:swap, 0, false), 1, 8, nothing)
GateCall2(GateSymbol(:swap, 0, false), 2, 7, nothing)
GateCall2(GateSymbol(:swap, 0, false), 3, 6, nothing)
GateCall2(GateSymbol(:swap, 0, false), 4, 5, nothing)
GateCall1(GateSymbol(:h, 0, false), 8)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -1.5707963267948966), 7, 8, nothing)
GateCall1(GateSymbol(:h, 0, false), 7)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.7853981633974483), 6, 8, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -1.5707963267948966), 6, 7, nothing)
GateCall1(GateSymbol(:h, 0, false), 6)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.39269908169872414), 5, 8, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.7853981633974483), 5, 7, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -1.5707963267948966), 5, 6, nothing)
GateCall1(GateSymbol(:h, 0, false), 5)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.19634954084936207), 4, 8, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.39269908169872414), 4, 7, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.7853981633974483), 4, 6, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -1.5707963267948966), 4, 5, nothing)
GateCall1(GateSymbol(:h, 0, false), 4)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.09817477042468103), 3, 8, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.19634954084936207), 3, 7, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.39269908169872414), 3, 6, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.7853981633974483), 3, 5, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -1.5707963267948966), 3, 4, nothing)
GateCall1(GateSymbol(:h, 0, false), 3)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.04908738521234052), 2, 8, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.09817477042468103), 2, 7, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.19634954084936207), 2, 6, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.39269908169872414), 2, 5, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.7853981633974483), 2, 4, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -1.5707963267948966), 2, 3, nothing)
GateCall1(GateSymbol(:h, 0, false), 2)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.02454369260617026), 1, 8, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.04908738521234052), 1, 7, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.09817477042468103), 1, 6, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.19634954084936207), 1, 5, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.39269908169872414), 1, 4, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -0.7853981633974483), 1, 3, nothing)
GateCall2(GateSymbolP(:c_r_phase, 0, false, -1.5707963267948966), 1, 2, nothing)
GateCall1(GateSymbol(:h, 0, false), 1)