Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
- MKL FFT - Real input data to comples result

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
##

Marek_C_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-03-2013
09:31 PM

64 Views

MKL FFT - Real input data to comples result

Hello everyone,

I am currently working on doing fft on my wav audio signal. My goal is to recreate Matlab's function called "spectrogram", which does a STFT with moving Hammington window.

My first attempt was to represent my input data as a vector (size of the window, padded with zeros) and output is vector with same size. It was working nice, I got almost the same result as other function in Matlab using fft.

But since Matlab spectrogram is giving me results represented as complex numbers, I want to do the same with MKL using C.

In user guide manual - page 2708, I can perform the fft by using this procedure:

status= DftiComputeForward(desc_handle, xre_in, xim_in, yre_out, yim_out);

So my thinking was to declare ** xre_in, xim_in, yre_out, yim_out** ad arrays of doubles,where: **xre_in** is vector of my input data, **xim_in** is vector with zeros.

FFT part looks like this:

status = DftiCreateDescriptor(&fft_handle, DFTI_DOUBLE, DFTI_REAL, 1, fftpoint);

status = DftiSetValue(fft_handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE);

status = DftiCommitDescriptor(fft_handle);

status = DftiComputeForward(fft_handle, Fft_input.pVector, input_imag.pVector, Fft_output.pVector, output_imag.pVector);

status = DftiFreeDescriptor(&fft_handle);

Unfortunately my outputs are all zeros after computing, so I guess my process of thinking was wrong. Where have I done mistake?

I am working with Visual Studio 2010, I don't think I have C99 standard, because I cannot declare complex numbers, and dealing with real ones is easier.

Regards,

Marek

3 Replies

Highlighted
##

Evgueni_P_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-03-2013
10:28 PM

64 Views

Hi Marek,

Please (1) change DFTI_REAL to DFTI_COMPLEX in DftiCreateDescriptor and (2) add the following line before DftiCommitDescriptor.

status = DftiSetValue(fft_handle, DFTI_COMPLEX_STORAGE, DFTI_REAL_REAL);

If you care about time taken by calls to MKL FFT routines, please look at examples/dftc/source/basic_dp_real_dft_1d.c (I assume that you use MKL 11) which explains how to compute only the first half of the output. The output will be stored in one array of complex numbers, real and imaginary parts interleaved. The second half of the output can be recovered as follows out

Thanks,

Evgueni.

Highlighted
##

Marek_C_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-03-2013
11:15 PM

64 Views

Thank you, I was able to somehow solve my problem, by not using my idea I presented here.

However I have one question. Why does MKL FFT do not produce symmetric fft?

Matlab for fftpoint = 4096 creates symmetric fft, but MKL only first half? (2048 samples are result, the rest is mirror image)

One data point in Matlab is represented by two after MKL's fft. Is it possible to change this somewhere?

Regards

Marek

Highlighted
##

Computing only the first half of the output is the documented behavior of MKL real-to-complex FFTs. It is the applications using MKL real-to-complex FFTs that are expected to restore the second half of the output. For example, you may add to your application a small inline function or a macro to this end.

Evgueni_P_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-03-2013
11:41 PM

64 Views

For more complete information about compiler optimizations, see our Optimization Notice.