0
$\begingroup$

The unitary matrix associated with the QFT circuit in Qiskit does not match the actual DFT matrix. In fact, all the imaginary components have their sign flipped (QFT and DFT matrices seems to be each other's complex conjugate). Is that the correct behavior?

Note that the QFT circuit already includes the swap gates at the end of the circuit.

import numpy as np
from scipy.linalg import dft
from qiskit import *
from qiskit.circuit.library import QFT

n = 2
dft_matrix = (1/np.sqrt(2**n)) * dft(2**n)
qft_matrix = execute(QFT(n), Aer.get_backend('unitary_simulator')).result().get_unitary()

# remove components almost zero for enhanced visualization
eps = 0.00001
dft_matrix.real[np.abs(dft_matrix.real) < eps] = 0
dft_matrix.imag[np.abs(dft_matrix.imag) < eps] = 0
qft_matrix.real[np.abs(qft_matrix.real) < eps] = 0
qft_matrix.imag[np.abs(qft_matrix.imag) < eps] = 0

dft_matrix, qft_matrix

The matrices have values:

dft_matrix=
array([[  0.5+0.j ,  0.5+0.j ,  0.5+0.j ,  0.5+0.j ],
        [ 0.5+0.j ,  0. -0.5j, -0.5+0.j ,  0. +0.5j],
        [ 0.5+0.j , -0.5+0.j ,  0.5+0.j , -0.5+0.j ],
        [ 0.5+0.j ,  0. +0.5j, -0.5+0.j ,  0. -0.5j]]),
qft_matrix=
array([[  0.5+0.j ,  0.5+0.j ,  0.5+0.j ,  0.5+0.j ],
        [ 0.5+0.j ,  0. +0.5j, -0.5+0.j ,  0. -0.5j],
        [ 0.5+0.j , -0.5+0.j ,  0.5+0.j , -0.5+0.j ],
        [ 0.5+0.j ,  0. -0.5j, -0.5+0.j ,  0. +0.5j]])
$\endgroup$
1
$\begingroup$

According to the docs of scipy and qiskit, the first uses primitive root $\omega = e^{-\frac{2\pi i}{n}}$ and the second uses $\omega = e^{\frac{2\pi i}{n}}$.

This implies that one matrix is complex conjugate of the other (which is the same as inverse).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.