I'm trying to compute the Discrete Cosine Transform via FFT in C, using a response to this question, but the recommended solution gives me wrong results.
Function DCT in matlab:
x = [0:1:7]
x = 0 1 2 3 4 5 6 7
dct(x)
ans = 9.8995, -6.4423, 0, -0.6735, 0, -0.2009, 0, -0.0507
Type 2 DCT using 2N FFT mirrored (Makhoul):
x = [0, 1, 2, 3, 4,5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0]
X = fft(x)[:N]
X = X * exp(-1j*pi*k/(2*N))
(the real path) X = 56.0000, -25.7693, 0.0, -2.6938, 0.0, -0.8036, 0.0, -0.2028
The data are not even close to each other.
If anyone has an implementation of the DCT, I would be grateful if you could share it.

