资源简介
基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++源码)
相关资源
- n个数冒泡排序法
- C语言课程设计文本编辑器
- 数据结构大作业(C语言)实验报告
- 游程编码C语言实现
- 基于89C51的0-99秒表计8个成绩电路图和
- 最速下降法c语言实现
- 优先级和时间片轮转调度实验算法c语
- 计网实验 数据链路层实验 源代码 C语
- 有限元的C语言实现计算
- 用C语言实现的的全部的古典密码学算
- c语言实现稀疏矩阵的加减乘,转置
- RSA算法C语言程序
- C语言试题库适合高职院校学生使用
- 智能电梯完整c程序
- 汉诺塔非递归算法 用栈 C语言
- C语言编写的扫雷exe文件,附排行榜
- 可变窗口的SAD相关匹配C语言程序
- CAN总线源代码c语言
- cs5532 的驱动程序C语言
- 如何用C语言编写步进电机驱动程序
- 文件转数组及C语言字符串工具
- 停车场管理系 C语言实现停车场管理
- 用C语言实现高斯-赛德尔迭代方法
- 21点游戏代码 C语言
- c语言链表的项目用链表实现的字典
- 用C语言实现图形菜单界面
- MSP430的C语言版跑马灯程序绝对可用
- c语言图形学鼠标点击画椭圆
- 实验3 C语言实现RC4加密算法报告
- C语言实现DES算法对任意文件加解密报
评论
共有 条评论