一维DFT
来源:互联网 发布:淘宝卖家查看店铺粉丝 编辑:程序博客网 时间:2024/04/23 16:01
学习DIP第3天
傅里叶变换是一个很大的话题,今天实现了下一维的DFT,后续将完成其他傅里叶系的算法实现和实验;
DFT公式:
- 其中e 是自然对数的底数,i是虚数单位。通常以符号表示这一变换,即
IDFT公式:
- 记为:
//// main.c// Fourer1D//// Created by Tony on 14/11/16.// Copyright (c) 2014年 Tony. All rights reserved.//#include <stdio.h>#include <stdlib.h>#include <time.h>#include <math.h>#define SIZE 1000#define VALUE_MAX 2000struct Complex_{ double real; double imagin;};typedef struct Complex_ Complex;void setInput(double * data,int n){ printf("Setinput signal:\n"); srand((int)time(0)); for(int i=0;i<SIZE;i++){ data[i]=rand()%VALUE_MAX; printf("%lf\n",data[i]); }}void DFT(double * src,Complex * dst,int size){ clock_t start,end; start=clock(); for(int m=0;m<size;m++){ double real=0.0; double imagin=0.0; for(int n=0;n<size;n++){ double x=M_PI*2*m*n; real+=src[n]*cos(x/size); imagin+=src[n]*(-sin(x/size)); } dst[m].imagin=imagin; dst[m].real=real; if(imagin>=0.0) printf("%lf+%lfj\n",real,imagin); else printf("%lf%lfj\n",real,imagin); } end=clock(); printf("DFT use time :%lf for Datasize of:%d\n",(double)(end-start)/CLOCKS_PER_SEC,size);}void IDFT(Complex *src,Complex *dst,int size){ //Complex temp[SIZE]; clock_t start,end; start=clock(); for(int m=0;m<size;m++){ double real=0.0; double imagin=0.0; for(int n=0;n<size;n++){ double x=M_PI*2*m*n/size; real+=src[n].real*cos(x)-src[n].imagin*sin(x); imagin+=src[n].real*sin(x)+src[n].imagin*cos(x); } real/=SIZE; imagin/=SIZE; if(dst!=NULL){ dst[m].real=real; dst[m].imagin=imagin; } if(imagin>=0.0) printf("%lf+%lfj\n",real,imagin); else printf("%lf%lfj\n",real,imagin); } end=clock(); printf("IDFT use time :%lfs for Datasize of:%d\n",(double)(end-start)/CLOCKS_PER_SEC,size); }int main(int argc, const char * argv[]) { double input[SIZE]; Complex dst[SIZE]; setInput(input,SIZE); printf("\n\n"); DFT(input, dst, SIZE); printf("\n\n"); IDFT(dst, NULL, SIZE); }
1 0
- 一维DFT
- 一维DFT C实现
- dft
- DFT
- 什么是DFT,DFT是什么意思
- [DFT] Spyglass DFT
- FFT & DFT
- opencv - DFT
- 二维DFT
- DFT/DTFT
- opencv dft
- opencv DFT
- opencv dft
- 数字信号处理公式变程序(一)——DFT、FFT
- DFT的AS2实现
- Some Link for DFT
- DFT(离散傅里叶变换)
- 离散傅立叶变换(DFT)
- IIS Express 启用目录浏览
- NYOJ 520 & HDU 2136 Largest prime factor(筛法思想)
- ORA-19815: WARNING: db_recovery_file_dest_size of 2147483648 bytes is 98.85% used
- rails开发流程
- iOS提交发布应用(Xcode5)到App Store 详细解析
- 一维DFT
- 网络基础
- 第十二周 求数的阶乘(递归算法)
- MongoDB 开篇
- JavaWeb——Day20_1
- HDU 4734F(x) 题解 (记忆化DP)
- ubuntu12.04 the system is running in low-graphics mode的解决方案
- [PAT]1004. Counting Leaves (30)
- IOS 7 下面 状态栏的字体改成白色