大家好我正在使用fftw C库来计算嵌入式系统上某些信号处理应用的频谱.但是,在我的项目中,我遇到了轻微的阻碍.
下面是我编写的一个简单程序,以确保我正确实现fftw函数.基本上我想计算12个数字序列的fft,然后做ifft并再次获得相同的数字序列.如果你安装了fftw3和gcc,那么如果用以下代码编译,这个程序应该可行:
gcc -g -lfftw3 -lm fftw_test.c -o fftw_test
目前我的fft长度与输入数组的大小相同.
#include <stdio.h>
#include <stdlib.h>
#include <sndfile.h>
#include <stdint.h>
#include <math.h>
#include <fftw3.h>
int main(void)
{
double array[] = {0.1, 0.6, 0.1, 0.4, 0.5, 0, 0.8, 0.7, 0.8, 0.6, 0.1,0};
//double array2[] = {1, 6, 1, 4, 5, 0, 8, 7, 8, 6, 1,0};
double *out;
double *err;
int i,size = 12;
fftw_complex *out_cpx;
fftw_plan fft;
fftw_plan ifft;
out_cpx = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*size);
out = (double *) malloc(size*sizeof(double));
err = (double …