mimiqcircuits.operations.gates.generalized.qft

Quantum Fourier Transform (QFT).

Classes

QFT(*args)

Quantum Fourier transform on num_qubits qubits.

class QFT(*args)[source]

Bases: Gate

Quantum Fourier transform on num_qubits qubits.

Implements the unitary

\[\frac{1}{2^{n/2}} \sum_{x=0}^{2^n-1} \sum_{y=0}^{2^n-1} e^{2\pi i \frac{xy}{2^n}} |y\rangle\langle \tilde{x}|\]

where \(\tilde{x}\) is \(x\) with its bits reversed: the input is read with the first qubit as the least significant bit, the output with the first qubit as the most significant bit. The decomposition uses Hadamard and controlled-phase gates and no final SWAPs. The inverse is QFT(n).inverse(). QFT() with no arguments returns a lazy expression that takes the number of qubits later.

The gate has no matrix representation: matrix() raises NotImplementedError.

Parameters:

num_qubits (int) – Number of qubits, at least 1.

Raises:

ValueError – If num_qubits is less than 1, or more than one argument is given.

Examples

>>> from mimiqcircuits import *
>>> c = Circuit()
>>> c.push(QFT(2), 1, 2)
3-qubit circuit with 1 instruction:
└── QFT @ q[1:2]

>>> c.push(QFT(2).inverse(), 1, 2)
3-qubit circuit with 2 instructions:
├── QFT @ q[1:2]
└── QFT† @ q[1:2]

>>> QFT(2).decompose()
2-qubit circuit with 3 instructions:
├── H @ q[1]
├── CP((1/2)*pi) @ q[0], q[1]
└── H @ q[0]