用FFTW3和C++评估高斯的傅立叶变换
Evaluating Fourier transform of a Gaussian with FFTW3 and C++
我尝试在C++中使用FFTW3来计算高斯函数的傅立叶变换。这是我的代码的主要部分
main(int argc, char** argv)
{
fftw_plan p;
complex<double> *in,*out;
long N=8;
//allocation of in and the fftw plan called
in=(complex<double>*) calloc(N,sizeof(complex<double>));
p=fftw_plan_dft_1d(N,(fftw_complex*)in,(fftw_complex*)in,FFTW_BACKWARD,FFTW_ESTIMATE);
//initialize the array in with the values of a Gaussian function
gaussianf(in,N);
//Fourier transform in
fftw_execute(p);
//write the result into a file
writeft(in,N);
fftw_destroy_plan(p);
}
由于数组已经用高斯值初始化,我希望输出也是高斯的,但实际上只有包络具有高斯形状。正如我在下面的数据中所显示的,可以看到一些负值已经出现。
#input values
#x real part imag part
-10 3.72008e-44 0
-7.5 3.72336e-25 0
-5 1.38879e-11 0
-2.5 0.00193045 0
0 1 0
2.5 0.00193045 0
5 1.38879e-11 0
7.5 3.72336e-25 0
#output
#x real part imag part
-10 1.00386 0
-7.5 -1.00273 0
-5 1 0
-2.5 -0.99727 0
0 0.996139 0
2.5 -0.99727 0
5 1 0
7.5 -1.00273 0
有人能告诉我我做错了什么吗?我真的很感谢你的帮助。非常感谢。
从C编程或FFTW调用的意义上讲,您没有做错任何事情:这些都是正确的值。高斯曲线FFT的实部确实在零附近振荡。如果绘制绝对值,它可能看起来更像您所期望的。
这些振荡是意料之中的。在实践中,需要使用窗口函数来减少这些振荡。http://en.wikipedia.org/wiki/Window_function
相关文章:
- OpenCV 傅里叶变换复杂输出问题
- 离散傅立叶变换C++
- 如何从2D数组为QHeightMapSurfaceDataProxy创建高度图以显示2D傅立叶变换结果
- 函数已知时的傅里叶变换
- DFT(离散傅里叶变换)与C++代码
- 为什么我的Cooley-Tukey和蛮力(傅立叶)算法给出的结果非常不同
- 快速傅立叶变换:使用模板化派生类'undefined reference'即使标头和.cpp文件匹配也会出错
- 快速傅里叶变换:第一个元素是正确的,但其余元素不正确
- 傅里叶变换高斯滤波器误差
- OPENCV CORTOUR 1D离散傅立叶变换
- 傅立叶变换浮点问题
- 使用FFTW并评估生成的傅立叶级数
- 用FFTW3和C++评估高斯的傅立叶变换
- 复数和朴素傅里叶变换 (C++).
- DFT(离散傅里叶变换)与C++ STL
- 离散傅立叶变换C++-下一步要做什么
- 如何在c++中执行二维快速傅里叶变换
- 快速傅立叶变换在WinForms
- c++中未定义的MKL傅立叶变换的引用
- 傅立叶变换规划中的访问冲突