资源简介
基2时间抽取算法的FFT算法 C语言实现,可用于上位机或者DSP开发
代码片段和文件信息
// fft -- a program to model a Fast Fourier Transform (FFT).
//
// Copyright (C) 2001 John Dalton
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not write to the Free Software
// Foundation Inc. 59 Temple Place - Suite 330 Boston MA 02111-1307 USA.
// Include required libraries
#include
#include
#include
#include
#include
//
// factor
//
// Return a factor of a number.
//
// Inputs: x = the number to be factored.
// Returns: A factor of ‘x‘. If ‘x‘ is a
// prime eith ‘x‘ or the number
// one will be returned.
//
long factor(long x)
{
long i;
for(i=2; i if(x%i==0) {
return(i);
}
}
return(1);
}
//Paramatise the type of each element
//to allow it to be changed easily
#define element_type double_complex
//This routine does one stage of an FFT.
//
// fft_stage
//
// Do a set of FFTs. The length of the FFT may be
// smaller than the length of the input sequence.
// In this case multiple FFTs will be performed.
// If the length of the FFT is a composite number
// it is recusively decomposed into smaller FFTs
// whose lengths are prime numbers. The elements
// of each FFT do not need to be consecutive.
//
// Inputs: in = A sequence of numbers to be transformed.
// fft_length = The number of points in each FFT
// grouping = The separation between each element
// within an FFT.
// Returns: The transformed sequence.
//
vector fft_stage(vector in int fft_length int grouping)
{
int x y;
vector out(in.size());
int f;
// cout<<“***FFT“<
// A DFT of length does nothing so just
// return the input
if(fft_length <=1) {
out = in;
return(out);
}
// Factorise the number of points in the DFT (if possible)
// so we can break it into two smaller DFTs
f = factor(fft_length);
// If the number of points in the DFT is a composite
// number (ie. can be factorised) divide it into
// two smaller DFTs. Recurse until the DFT has been
// decomposed into DTFs of prime length.
if(f!=fft_length &&f!=1) {
int P = f;
int Q = fft_length / f;
vector intermediate(in.size());
//Do a DFT along one dimension
intermediate = fft_stage(in P grouping*Q);
//Multiply by twiddle fact
- 上一篇:n个数冒泡排序法
- 下一篇:远程桌面(带C++源码)
相关资源
- C语言编程常见问题解答.pdf
- 操作系统c语言模拟文件管理系统844
- C语言开发实战宝典
- C++中头文件与源文件的作用详解
- C语言代码高亮html输出工具
- 猜数字游戏 c语言代码
- C语言课程设计
- 数字电位器C语言程序
- CCS FFT c语言算法
- 使用C语言编写的病房管理系统
- 通信过程中的RS编译码程序(c语言)
- 计算机二级C语言上机填空,改错,编
- 用回溯法解决八皇后问题C语言实现
- 简易教务管理系统c语言开发文档
- 操作系统课设 读写者问题 c语言实现
- 小波变换算法 c语言版
- C流程图生成器,用C语言代码 生成C语
- 3des加密算法C语言实现
- 简单的C语言点对点聊天程序
- 单片机c语言源程序(51定时器 八个按
- 个人日常财务管理系统(C语言)
- c语言电子商务系统
- 小甲鱼C语言课件 源代码
- 将图片转换为C语言数组的程序
- C语言实现的一个内存泄漏检测程序
- DES加密算法C语言实现
- LINUX下命令行界面的C语言细胞游戏
- 用单片机控制蜂鸣器播放旋律程序(
- 学校超市选址问题(数据结构C语言版
- 电子时钟 有C语言程序,PROTEUS仿真图
评论
共有 条评论