# Implementing QFT

I would like to know if there is a way to:

1. Implement Quantum 'Functions' e.g the QFT of QFT* containing several single-qubit operations?
2. Implement such operations on an arbitrary number of qubits and in the same vein implement work-qubits.

Not looking as responsive as pyquil, however, I noticed in the Qiskit documentation that implementing a 'CircuitFactory' with the 'ABC' package seems to be the way to go. I would just appreciate insights from experienced hands. Thank you kindly.

• What I see an inherent problem: ideally, a quantum field is an infinite dimensional quantum system. Thus, we would need $\infty$ qubits to describe it. But there is likely some approximation. Oct 31 '20 at 18:44
• @peterh-ReinstateMonica My guess is that QFT in this question stands for quantum Fourier transform and not quantum field theory. An unfortunate overlap of acronyms. Nov 2 '20 at 20:00
• @Rammus Oops, thanks! :-) Nov 2 '20 at 21:46

If I understand your question correctly, you are looking for a way to create custom gates.

For that, first create a circuit that it will be converted to a gate:

from qiskit import *
my_circuit = QuantumCircuit(3, name='mygate')
my_circuit.x(range(3))
....
my_gate = my_circuit.to_gate()


Then, you can use your gate in a bigger circuit:

circuit = QuantumCircuit(5)
circuit.append(my_gate, [0,2,3])
print(circuit)

     ┌──────────┐
q_0: ┤0         ├
│          │
q_1: ┤          ├
│  my_gate │
q_2: ┤1         ├
│          │
q_3: ┤2         ├
└──────────┘
q_4: ────────────


You can see your custom gate "content" with circuit.decompose().