I'm trying to implement a 2 dimensional fourier transform via use of MKL FFT functions.
I'm interested in transforming from the space domain (i.e., my input signal is a 2D MxN matrix of `double`s) to the frequency domain (i.e., a 2D MxN output matrix of complexes with double accuracy, `MKL_Complex16`) and then back to the space domain after some filtering.
Based on the examples provided by intel's MKL implementation (i.e., basic_dp_real_dft_2d.c etc.) I've created the following matlab-ish function:
bool fft2(double *in, int m, int n, MKL_Complex16 *out) { bool ret(false); DFTI_DESCRIPTOR_HANDLE hand(NULL); MKL_LONG dim[2] = {m, n}; if(!DftiCreateDescriptor(&hand, DFTI_DOUBLE, DFTI_REAL, 2, dim)) { if(!DftiSetValue(hand, DFTI_PLACEMENT, DFTI_NOT_INPLACE)) { if(!DftiSetValue(hand, DFTI_CONJUGATE_EVEN_STORAGE, DFTI_COMPLEX_COMPLEX)) { MKL_LONG rs[3] = {0, n, 1}; if(!DftiSetValue(hand, DFTI_INPUT_STRIDES, rs)) { MKL_LONG cs[3] = {0, n / 2 + 1, 1}; if(!DftiSetValue(hand, DFTI_OUTPUT_STRIDES, cs)) { if(!DftiCommitDescriptor(hand)) { ret = !DftiComputeForward(hand, in, out)); } } } } } } DftiFreeDescriptor(&hand); return ret; }
Due to the fact that I want to do some DSP stuff (e.g., Gaussian filtering) and thus I have to do matrix multiplications. I want the full transformation matrix instead of the CCE format in C matrix that DftiComputeForward outputs.
**How can I reconstruct the full transformation matrix of an arbitrary sized 2d signal (i.e., matrix) from the CCE format in C matrix that I get as output from DftiComputeForward function?**
For example if I have the following 2D real signal:
0.1, 0.2, 0.3
0.4, 0.5, 0.6
0.7, 0.8, 0.9
It's full transformation matrix would be:
4.5 + 0j, -0.45 + 0.259808j, -0.45 - 0.259808j
-1.35 + 0.779423j, 0 - 0j, 0 - 0j
-1.35 - 0.779423j, 0 + 0j, 0 + 0j
However the result from `DftiComputeForward` in CCE is:
4.5 + 0j, -0.45 + 0.259808j, -1.35 + 0.779423j,
0 - 0j, -1.35 - 0.779423j, 0 + 0j,
0 + 0j, 0 + 0j, 0 + 0j