Problem computation of1D FFT

Problem computation of1D FFT

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] = i+1;

	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[i]);
	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?

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


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.

By the way, you can read about the formats in the online documentation  from here

Leave a Comment

Please sign in to add a comment. Not a member? Join today