本文代码中FFT使用递归版本实现
FFT加速多项式乘法原理不多说了,直接贴代码如下:
在vs2017上测试成功
#include "pch.h"
#define _CRT_SECURE_NO_WARNINGS
#include "stdlib.h"
#include "math.h"
#include "stdio.h"
#define N 8
#define MAXN 100
#define Pi 3.1415927 //定义圆周率Pi
#define LEN sizeof(struct Compx) //定义复数结构体大小
//-----定义复数结构体-----------------------
typedef struct Compx
{
double real;
double imag;
}Compx;
//-----复数乘法运算函数---------------------
struct Compx mult(struct Compx b1, struct Compx b2)
{
struct Compx b3;
b3.real = b1.real*b2.real - b1.imag*b2.imag;
b3.imag = b1.real*b2.imag + b1.imag*b2.real;
return(b3);
}
//-----复数减法运算函数---------------------
struct Compx sub(struct Compx a, struct Compx b)
{
struct Compx c;
c.real = a.real - b.real;
c.imag = a.imag - b.imag;
return(c);
}
//-----复数加法运算函数---------------------
struct Compx add(struct Compx a, struct Compx b)