Community
cancel
Showing results for 
Search instead for 
Did you mean: 
c__a
Beginner
49 Views

Problems with ippsFFTInv_CToC

Hi,
I observe a very strange behaviour of ippsFFTInv_CToC: the results are multiplied by the FFT length even if IPP_FFT_NODIV_BY_ANY is used as a flag for FFTSpec allocation.
Below is my example code, which generates a signal, performs an FFT on it and afterwards an IFFT on the output of the FFT. I would expect the final output to be exactly the same as the generated signal (except for rounding error of course), but this is not the case: the output values need to be divided by the FFT length in order to be correct.
As far as I could understand by reading the documentation, it doesnt seem to me that this behaviour is correct. But maybe I am making some mistake.
Any help would be greatly appreciated.
[cpp]void fftIPPTest()
{
	unsigned int nDataPow2 = 1024;
	unsigned int order = 10;

	Ipp64fc* input  = ippsMalloc_64fc(nDataPow2);
	Ipp64fc* output = ippsMalloc_64fc(nDataPow2);
	Ipp64fc* output_ifft = ippsMalloc_64fc(nDataPow2);

	ippsZero_64fc(input, nDataPow2);
	ippsZero_64fc(output, nDataPow2);
	ippsZero_64fc(output_ifft, nDataPow2);

	/*Generate some signal*/
	for (int i = 0; i < nDataPow2; i++)
	{
		input.re = i;
		input.im = i;
	}

	IppsFFTSpec_C_64fc* fftConfig;
	IppStatus st = ippsFFTInitAlloc_C_64fc(&fftConfig, order,
	IPP_FFT_NODIV_BY_ANY, ippAlgHintAccurate);

	/*FFT*/ 
	st = ippsFFTFwd_CToC_64fc(input, output, fftConfig, NULL);

	/*IFFT*/
	st = ippsFFTInv_CToC_64fc(output, output_ifft, fftConfig, NULL);

	for (int i = 0; i < nDataPow2; i++)
	{
		Ipp64f diff_re = input.re - output_ifft.re;
		Ipp64f diff_im = input.im - output_ifft.im;

		printf("-----\n");
		printf("%d re: in ->  %e | out -> %e | diff: %e\n", 
						i, input.re, output_ifft.re, diff_re);
		printf("%d im: in ->  %e | out -> %e | diff: %e\n", 
						i, input.im, output_ifft.im, diff_im);
		printf("-----\n");
	}

	st = ippsFFTFree_C_64fc(fftConfig);
	ippsFree(input);
	ippsFree(output);
	ippsFree(output_ifft);

}[/cpp]
0 Kudos
2 Replies
Chao_Y_Intel
Employee
49 Views

Hi AC,

According to FFT formula, either forward transform is done with the 1/N normalization, or inverse transform is done

With the 1/N normalization, or forward and inverse transform is done with the N^1/2 normalization, the input and out will get same result.

so, it needs to use one of the following flags:

IPP_FFT_DIV_FWD_BY_N/IPP_FFT_DIV_INV_BY_N/IPP_FFT_DIV_BY_SQRTN.

Thanks,
Chao

c__a
Beginner
49 Views

Ok, I got it now.
Thanks.
Reply