问题描述
/ *使用Visual Studio 2015在C中实现* /
/*Implementing in C using Visual Studio 2015*/
#include" stdio.h"
#include" math.h"
#include" complex.h"
#include " conio.h"
双倍PI;
typedef double complex cplx;
void _fft(cplx buf [],cplx out [],int n,int step)
{
if(step< n){
_fft(out,buf,n,step * 2) ; $
_fft(out + step,buf + step,n,step * 2);
for(int i = 0; i< n; i + = 2 * step){
cplx t = cexp(-I * PI * i / n)* out [i + step];
buf [i / 2] = out [i] + t;
buf [(i + n)/ 2] = out [i] - t;
}
}
}
$
void fft(cplx buf [],int n)
{
cplx out [n];
for(int i = 0;我< N; i ++)out [i] = buf [i];
$
_fft(buf,out, n,1);
}
void show(const char * s,cplx buf [] ){
printf("%s",s);
for(int i = 0; i< 8; i ++)
if (!cimag(buf [i]))
printf("%g",creal(buf [i]) ); $
其他
printf("(%g,%g)",creal(buf [i]),cimag(buf [i]));
}
int main()
{
PI = atan2(1, 1)* 4;
cplx buf [] = {1,1,1,1,0,0,0,0 }
show(" Data:",buf);
fft(buf,8);
show(" \ nFFT:",buf);
_getch();
返回0 ;
}
#include "stdio.h"
#include "math.h"
#include "complex.h"
#include "conio.h"
double PI;
typedef double complex cplx;
void _fft(cplx buf[], cplx out[], int n, int step)
{
if (step < n) {
_fft(out, buf, n, step * 2);
_fft(out + step, buf + step, n, step * 2);
for (int i = 0; i < n; i += 2 * step) {
cplx t = cexp(-I * PI * i / n) * out[i + step];
buf[i / 2] = out[i] + t;
buf[(i + n) / 2] = out[i] - t;
}
}
}
void fft(cplx buf[], int n)
{
cplx out[n];
for (int i = 0; i < n; i++) out[i] = buf[i];
_fft(buf, out, n, 1);
}
void show(const char * s, cplx buf[]) {
printf("%s", s);
for (int i = 0; i < 8; i++)
if (!cimag(buf[i]))
printf("%g ", creal(buf[i]));
else
printf("(%g, %g) ", creal(buf[i]), cimag(buf[i]));
}
int main()
{
PI = atan2(1, 1) * 4;
cplx buf[] = { 1, 1, 1, 1, 0, 0, 0, 0 };
show("Data: ", buf);
fft(buf, 8);
show("\nFFT : ", buf);
_getch();
return 0;
}
/ *
错误:
标识符" cplx"未定义
identifier "cplx" is undefined
* /
推荐答案
MSVC不支持大多数C99功能。特别是,它不支持"双重复合"。类型。
MSVC doesn't support most C99 features. In particular, it doesn't support "double complex" type.
这篇关于面对在Visual Studio 2015中实现包含complex.h的程序的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!