#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#define pi atan(1)*4
typedef struct{
double real;
double imag; //the structure to discribe plural
}plural;
void reverse(plural *x,int size_x); //码位倒序
void output(plural *x,int size_x); //输出
void add(plural,plural,plural *);
void sub(plural,plural,plural *);
void mul(plural,plural,plural *); //复数运算
void fft(plural *x,int size_x); //基二时域
void fft2(plural *x,int size_x); //基二频域
void ifft(plural *x,int size_x);
void ifft2(plural *x,int size_x);
void linear_convolution(plural *,int,plural*,int,plural *); //线性卷积
void fast_convolution1(plural *,int,plural*,int,plural *,int size_x); // 基二时域的快速卷积
void fast_convolution2(plural *,int,plural*,int,plural *,int size_x); // 基二频域的快速卷积
/*_^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^_*/
int main(void)
{
int i;
plural x1[1024],y1[1024],c1[1024];
plural x2[1024],y2[1024],c2[1024];
plural x3[1024],y3[1024],c3[1024];
int size_x=512;
int op1,end1,op2,end2,op3,end3;
for(i=0;i<size_x;i++)
{
x1[i].real=i+1;
x2[i].real=i+1;
x3[i].real=i+1;
y1[i].real=i+3;
y2[i].real=i+3;
y3[i].real=i+3;
x1[i].imag=i;
y1[i].imag=i;
x2[i].imag=i;
y2[i].imag=i;
x3[i].imag=i;
y3[i].imag=i;
}
//以上是初始化序列
printf("the answer of fast_convolution2 is:\n");
op1=clock();
fast_convolution2(x1,2*size_x, y1,2*size_x, c1,2*size_x);
end1=clock();
output(c1,2*size_x);
printf("\n\nthe answer of fast_convolution1 is:\n");
op2=clock();
fast_convolution1(x2,2*size_x, y2,2*size_x, c2,2*size_x);
end2=clock();
output(c2,2*size_x);
printf("\n\nthe answer for linear_convolution is : \n");
op3=clock();
linear_convolution(x3,size_x,y3,size_x,c3);
end3=clock();
output(c3,2*size_x);
printf("\n\n\n
#include <math.h>
#include <stdlib.h>
#include <time.h>
#define pi atan(1)*4
typedef struct{
double real;
double imag; //the structure to discribe plural
}plural;
void reverse(plural *x,int size_x); //码位倒序
void output(plural *x,int size_x); //输出
void add(plural,plural,plural *);
void sub(plural,plural,plural *);
void mul(plural,plural,plural *); //复数运算
void fft(plural *x,int size_x); //基二时域
void fft2(plural *x,int size_x); //基二频域
void ifft(plural *x,int size_x);
void ifft2(plural *x,int size_x);
void linear_convolution(plural *,int,plural*,int,plural *); //线性卷积
void fast_convolution1(plural *,int,plural*,int,plural *,int size_x); // 基二时域的快速卷积
void fast_convolution2(plural *,int,plural*,int,plural *,int size_x); // 基二频域的快速卷积
/*_^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^_*/
int main(void)
{
int i;
plural x1[1024],y1[1024],c1[1024];
plural x2[1024],y2[1024],c2[1024];
plural x3[1024],y3[1024],c3[1024];
int size_x=512;
int op1,end1,op2,end2,op3,end3;
for(i=0;i<size_x;i++)
{
x1[i].real=i+1;
x2[i].real=i+1;
x3[i].real=i+1;
y1[i].real=i+3;
y2[i].real=i+3;
y3[i].real=i+3;
x1[i].imag=i;
y1[i].imag=i;
x2[i].imag=i;
y2[i].imag=i;
x3[i].imag=i;
y3[i].imag=i;
}
//以上是初始化序列
printf("the answer of fast_convolution2 is:\n");
op1=clock();
fast_convolution2(x1,2*size_x, y1,2*size_x, c1,2*size_x);
end1=clock();
output(c1,2*size_x);
printf("\n\nthe answer of fast_convolution1 is:\n");
op2=clock();
fast_convolution1(x2,2*size_x, y2,2*size_x, c2,2*size_x);
end2=clock();
output(c2,2*size_x);
printf("\n\nthe answer for linear_convolution is : \n");
op3=clock();
linear_convolution(x3,size_x,y3,size_x,c3);
end3=clock();
output(c3,2*size_x);
printf("\n\n\n