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

Problem computation of1D FFT

flexwang
Beginner
253 Views

I want to compute a 1d fft with dfti.

Here is my code

#include "mkl_dfti.h"
#include <stdio.h>

int main()
{
	float y[8];

	for (int i=0; i<4; i++) {
		y = i+1;
	}

	DFTI_DESCRIPTOR_HANDLE handle;
	MKL_LONG status;
	status = DftiCreateDescriptor( &handle, DFTI_SINGLE, DFTI_REAL, 1, 4 );
	status = DftiCommitDescriptor( handle);
	status = DftiComputeForward( handle,&y[0] );
	status = DftiFreeDescriptor( &handle );

	for (int i=0; i<8; i++) {
		printf("%.2f ", y);
	}
	return 0;
}

The result should be 10  0 -2  2 -2 0 -2 -2, however, instead it only outputs the first six number, and the last two numbers are just chaos. Why?

0 Kudos
2 Replies
VipinKumar_E_Intel
253 Views

 

The result from MKL is correct, in real-to-complex tranforms, the packed format of complex numbers is used (to save memory).  In your case, the default format is CCS, and MKL guarantees only 10.00 0.00 -2.00 2.00 -2.00 0.00 output.  As it outputs only near half of complex numbers, the last half can be recovered from previous one, because of the conjugate-even symmetry feature of r2c transforms.

0 Kudos
VipinKumar_E_Intel
253 Views

By the way, you can read about the formats in the online documentation  from here http://software.intel.com/en-us/node/470850

0 Kudos
Reply