2024年1月8日发(作者:)
Visual Studio 2008下安装FFTW
简介
FFFTW是一个来计算一维或者多维离散时间傅立叶变换(DFT)的C库,可以计算任意输入大小,实数和虚数以及奇偶数据(离散余弦/离散正弦变换,DCT/DST)。FFTW,将成为FFT的C库,是更多应用的佳选。详细介绍请参考/。
1. FFTW in VS2008
选自/install/ 的Windows Installation Note
We have created precompiled DLL files for FFTW 3.3 in single/double/long-double precision,
along with the associated test programs. We hope that these are sufficient for most users, so that
you need not worry about compiling FFTW:
32-bit version: (1.8MB)
64-bit version: (2.2MB)
These DLLs were created by us, cross-compiled from GNU/Linux using MinGW; the 64-bit
version is possible thanks to the mingw-w64 project. You should be able to call them from any
compiler. In order to link to them from Visual C++, you will need to create .lib "import libraries"
using the program included with VC++. Run:
lib /def:
lib /def:
lib /def:
这里要注意电脑CPU是32还是64位。
2. README-WINDOWS File in
In order to link to these .dll files from Visual C++, you need to create .lib "import libraries"
for them, and can do so with the "lib" command that comes with VC++. In particular, run:
lib /def:
lib /def:
lib /def:
用VS2008编译产生、 和 .
找到路径cd 命令之后直接拖动文件夹就可以找到路径
提示:
如果VS2008和fftw-3.3-dll32不在一个分区下,拖动之后要输入fftw-3.3-dll32所在路径的盘符截图如下
如果VS2008和fftw-3.3-dll32在一个分区下,直接cd 然后拖动就行了
依次输入命令
lib /def:
lib /def:
lib /def:
这里忽略警告(具体原因不明),警告不是错误。
3. 设置VS2008编译器。
根据个人的爱好建立文件按夹
fftw
bin *dll
lib *.lib 和*.def
include *.h
如图
5.设置VS2008
打开VS2008设置,一定要注意在配置前先导出设置,便于必要的时候恢复配置,具体在工具>导入导出设置>导出选定的环境设置>下一步>下一步>完成就行。
工具>选项>VC++目录
可执行文件指定的bin目录
包含文件指定到 include目录
库文件指定到lib目录
6.测试一下
在文件中必须包含fftw.h头文件。
写入下面代码
1. // : 定义控制台应用程序的入口点。
2. //
3.
4. #include "stdafx.h"
5. #include
6. #pragma comment(lib, "")
7. #pragma comment(lib, "")
8. #pragma comment(lib, "")
9.
10. #define _USE_MATH_DEFINES
11. #include
12.
13. int main(int argc, char* argv[])
14. {
15. const int kSamples = 16;
16.
17. fftw_complex *in = reinterpret_cast
18. fftw_complex *out = reinterpret_cast
19.
20. for (int t = 0; t < kSamples; t++ ) {
21. in[t][0] = sin(2.0 * M_PI * static_cast
22. in[t][1] = 0;
23. }
24.
25. fftw_plan p = fftw_plan_dft_1d(kSamples, in, out,
FFTW_FORWARD, FFTW_ESTIMATE);
26. fftw_execute(p);
27.
28. for (int t = 0; t < kSamples; t++ ) {
29. printf("%02dt%+5.2f%+5.2fin", t, out[t][0],
out[t][1]);
30. }
31.
32. return 0;
33. }
运行
系统错误提示
解决办法直接将目录中原有的,,文件复制到C:WindowsSystem32中。这一步是为了你以后都不用在你的可执行文件所在的文件夹中查找,因为系统直接会去system32中找。
运行结果
分析这个程序是计算
其他都为0.
n(u[n]-u[n-16])的FFT变换,很容易知道在n=1,和15非零,


发布评论