迭代版的快速傅里叶转换 (FFT),C语言实现

本文介绍了使用C语言实现的迭代版快速傅里叶转换(FFT)算法,详细展示了翻译自https://blog.csdn.net/weixin_33714884/article/details/94249560的代码。测试表明,当数据规模小于等于50时,算法运行正常,但规模扩大到500时出现错误,而递归版本的FFT则无此问题。文中提出了关于蝴蝶操作是否必须使用位操作的疑问。
摘要由CSDN通过智能技术生成

这是迭代版的快速傅里叶转换 (FFT)。其实就是翻译了一下https://blog.csdn.net/weixin_33714884/article/details/94249560?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.channel_param中的代码。
实际测试发现两个数组的规模都比较小 (<= 50) 的时候,运行是正常的。但是当数据规模到500时,软件就运行出错。不清楚原因。但是用递归版本就没问题。

下面是代码:

#include <stdio.h> 
#include <stdlib.h>
#include <math.h>
#include <time.h>

double PI = 3.1415926;
int lim = 1;
int r[1000];
int l;

//定义复数 
struct Complex{
   
	double x; //实部 
	double y; //虚部 
};

struct Complex add(struct Complex a, struct Complex b)//复数的加法 
{
   
	struct Complex c;
	c.x = a.x + b.x;
	c.y = a.y + b.y;
	return c;
}

struct Complex myMinus(struct Complex a, struct Complex b) //复数的减法
{
   
	struct Complex c;
	c.x = a.x - b.x;
	c.y = a.y - b.y;
	return c;
}

struct Complex multiply(struct Complex a, struct Complex b) //复数的乘法
{
   
	struct Complex c;
	c.x = a.x * b.x - a
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值