I inherited an old fortran code with fft subroutine and I am unable to trace the source of that program. The only thing I know is that there is a call to ff2prp() and the call to fft2() to perform 2D forward and backward DFT. In order to know what the code is doing I take DFT of a 4x4 2D array (matrix) and the results are very different from Matlab and FFTW results.
Question: Can someone tell what the code is doing by looking at the output. The input and output are both real arrays
Input array
0.20000 0.30000 1.00000 1.20000
0.00000 12.00000 5.00000 1.30000
0.30000 0.30000 1.00000 1.40000
0.00000 0.00000 0.00000 1.50000
After forward FFT with fft2() fortran routine
0.16875 -0.01875 -0.05000 0.05625
0.00000 12.00000 5.00000 1.30000
0.30000 0.30000 1.00000 1.40000
0.00000 0.00000 0.00000 1.50000
Matlab output performing DCT: dct2(input)
6.3750 -0.8429 -3.4250 -2.4922
2.4620 0.6181 -2.6356 -0.9887
-4.2750 -0.9798 4.2250 2.2730
-4.8352 -1.2387 5.0695 3.4819
Output from C++ code using FFTW library. DCT from FFTW
(6.3750, 0.00) (-0.8429, 0.00) (-3.4250, 0.00) (-2.4922, 0.00)
(2.4620, 0.00) (0.6181, 0.00) (-2.6356, 0.00) (-0.9887, 0.00)
(-4.2750, 0.00) (-0.9798, 0.00) (4.2250, 0.00) (2.2730, 0.00)
(-4.8352, 0.00) (-1.2387, 0.00) (5.0695, 0.00) (3.4819, 0.00)
Forward FFT with Matlab - fft2(input)
25.5000 + 0.0000i -6.5000 - 7.2000i -10.5000 + 0.0000i -6.5000 + 7.2000i
-0.3000 -16.8000i -12.3000 + 4.8000i 0.1000 + 6.8000i 12.1000 + 5.2000i
-14.1000 + 0.0000i 3.5000 +11.2000i 9.1000 + 0.0000i 3.5000 -11.2000i
-0.3000 +16.8000i 12.1000 - 5.2000i 0.1000 - 6.8000i -12.3000 - 4.8000i
Forward FFT with FFTW
(25.50, 0.00) (-6.50, -7.20) (-10.50, 0.00) (-6.50, 7.20)
(-0.30, -16.80) (-12.30, 4.80) (0.10, 6.80) (12.10, 5.20)
(-14.10, 0.00) (3.50, 11.20) (9.10, 0.00) (3.50, -11.20)
(-0.30, 16.80) (12.10, -5.20) (0.10, -6.80) (-12.30, -4.80)
As you cane see the output of Matlab and FFTW agrees with each other but not with the output of the fortran code. I would like to use FFTW but the results are different due to FFT. I can't figure out what FFT the fortran program is doing. Can anyone tell by looking at the output.