我正在做一维FFT。我有与FFTW相同的输入数据,然而,CUFFT的返回似乎不像FFTW那样“对齐”。也就是说,在我的FFTW代码中,我可以计算零填充的中心,然后进行一些移位以“左对齐”我的所有数据,并具有尾随零。
在CUFFT中,FFT的结果是看起来相同的数据,但是,零在输出中不是“居中”的,所以我的算法的其余部分中断了。(转换到左对齐的数据在错误的转换之后仍然有一个“间隙”)。
有人能给我一些见解吗?我认为这与这些兼容性标志有关,但即使使用cufftSetCompatibilityMode(plan,CUFFT_COMPATIBILITY_FFTW_ALL),我仍然得到了一个糟糕的结果。
下面是来自第一行的数据量的曲线图。左边的数据是逆CUFFT的输出,右边的输出是逆FFTW的输出。
谢谢!

以下是FFTW和CUFFT计划的设置代码
ifft = fftwf_plan_dft_1d(freqCols, reinterpret_cast<fftwf_complex*>(indata),
reinterpret_cast<fftwf_complex*>(outdata),
FFTW_BACKWARD, FFTW_ESTIMATE);CUFFT:
cufftSetCompatibilityMode(plan, CUFFT_COMPATIBILITY_FFTW_ALL);
cufftPlan1d(&plan, width, CUFFT_C2C, height);和执行代码:
fftwf_execute(ifft);CUFFT:
cufftExecC2C(plan, d_image, d_image, CUFFT_INVERSE); //in place inverse完成了一些测试代码:
complex<float> *input = (complex<float>*)fftwf_malloc(sizeof(fftwf_complex) * 100);
complex<float> *output = (complex<float>*)fftwf_malloc(sizeof(fftwf_complex) * 100);
fftwf_plan ifft;
ifft = fftwf_plan_dft_1d(100, reinterpret_cast<fftwf_complex*>(input),
reinterpret_cast<fftwf_complex*>(output),
FFTW_BACKWARD, FFTW_ESTIMATE);
cufftComplex *inplace = (cufftComplex *)malloc(100*sizeof(cufftComplex));
cufftComplex *d_inplace;
cudaMalloc((void **)&d_inplace,100*sizeof(cufftComplex));
for(int i = 0; i < 100; i++)
{
inplace[i] = make_cuComplex(cos(.5*M_PI*i),sin(.5*M_PI*i));
input[i] = complex<float>(cos(.5*M_PI*i),sin(.5*M_PI*i));
}
cutilSafeCall(cudaMemcpy(d_inplace, inplace, 100*sizeof(cufftComplex), cudaMemcpyHostToDevice));
cufftHandle plan;
cufftPlan1d(&plan, 100, CUFFT_C2C, 1);
cufftExecC2C(plan, d_inplace, d_inplace, CUFFT_INVERSE);
cutilSafeCall(cudaMemcpy(inplace, d_inplace, 100*sizeof(cufftComplex), cudaMemcpyDeviceToHost));
fftwf_execute(ifft);当我转储这两个FFT调用的输出时,它看起来确实是一样的。不过,我不太确定我看到的是什么。数据在第75行的值为100。对吗?
发布于 2011-09-27 04:31:18
看起来您可能已经将输入中复杂数据的实部和虚部交换到了其中一个IFFT。此交换将在时域中将偶函数更改为奇函数。
https://stackoverflow.com/questions/7558384
复制相似问题