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 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.


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

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui