Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

1D - FFT

sicb0161
Beginner
1,368 Views
Hi,

I am a newbie using the FFT, I have some question about the input and output data format using the FFT Functions.

[cpp]  DFTI_DESCRIPTOR *my_desc_handle;
  long status;
  status = DftiCreateDescriptor( &my_desc_handle, DFTI_SINGLE, DFTI_REAL, 1, N);
  status = DftiCommitDescriptor( my_desc_handle);
  status = DftiComputeForward( my_desc_handle, y);
  status = DftiFreeDescriptor( &my_desc_handle );[/cpp]

Well, my input data y is real. After the transformation y contains not only real but also imaginary data. Is there a workaround ?

thx
0 Kudos
5 Replies
Dmitry_B_Intel
Employee
1,368 Views

Hi,

It depends on what you need from the spectrum y. If you want to discard the phase and use the power, you should use the magnitude (sqrt(re^2+im^2)) of the y's complex numbers.
Alternatively, if you needa real-to-real transform, look into trigonometric transforms section of MKL Refernce Manual.

Dima
0 Kudos
Dmitry_B_Intel
Employee
1,368 Views

Hi,

It depends on what you need from the spectrum y. If you want to discard the phase and use the power, you should use the magnitude (sqrt(re^2+im^2)) of the y's complex numbers.
Alternatively, if you needa real-to-real transform, look into trigonometric transforms section of MKL Reference Manual.

Dima
0 Kudos
ArturGuzik
Valued Contributor I
1,368 Views
Quoting - sicb0161
Hi,

I am a newbie using the FFT, I have some question about the input and output data format using the FFT Functions.

[cpp]  DFTI_DESCRIPTOR *my_desc_handle;
long status;
status = DftiCreateDescriptor( &my_desc_handle, DFTI_SINGLE, DFTI_REAL, 1, N);
status = DftiCommitDescriptor( my_desc_handle);
status = DftiComputeForward( my_desc_handle, y);
status = DftiFreeDescriptor( &my_desc_handle );[/cpp]

Well, my input data y is real. After the transformation y contains not only real but also imaginary data. Is there a workaround ?

thx
Hi,

if I recall correctly you need to use DFTISetValue and select (from many) options you need, say, something along the lines:
[cpp]! set packed format for output complex conjugate-symmetric data
status%flag=DFTISetValue(desc_handle, ....., .....)[/cpp]
where ..... go for named constants. (for example DFTI_REAL_REAL)

Take a look at Named Constants and storage schemes. I believe you'll find many good examples on disk.


A.
0 Kudos
sicb0161
Beginner
1,368 Views

Hi,

It depends on what you need from the spectrum y. If you want to discard the phase and use the power, you should use the magnitude (sqrt(re^2+im^2)) of the y's complex numbers.
Alternatively, if you needa real-to-real transform, look into trigonometric transforms section of MKL Refernce Manual.

Dima
Thx Dima ,

Hi, yes I could do so, but I only want to have the real part of y. After computing the FFT, y contains imaginary and real data. To be more precise :
[cpp]y = (real part) if i = even,  
       (imag part) if i = odd.[/cpp]
But y is only of length n , thus only containing half the data.

Thx
0 Kudos
Dmitry_B_Intel
Employee
1,368 Views
Right, for size=N real-to complex transform the y contains only N/2+1 complex values. The remaining values can be restored using conjugate-even symmetry of y: y[N-n]=conj(y).
Dima
0 Kudos
Reply