Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
fft1.cpp
Package: vc图像处理比较全面的程序.rar [view]
Upload User: alisonmail
Upload Date: 2013-02-28
Package Size: 500k
Code Size: 1k
Category:
Picture Viewer
Development Platform:
Visual C++
- #include "stdafx.h"
- #include "complex"
- using namespace std; //very important
- #define PI 3.1415926
- typedef complex<double> complexd; //use template
- void myfft(double y[][2], int N) //N is the power of 2 (as 8,64, 1024)
- {
- complexd t1,t2,t;
- int u,mu,i,j,k,n,l,s;
- complexd *w = new complexd[N/2];
- complexd *x = new complexd[N];
- mu=0; u=N-1;
- while (u>0) {mu++; u/=2;};
- for (i=0; i<N; i++) x[i]=complexd(y[i][0],y[i][1]);
- for (i=0; i<N; i++) { //sort input number array
- k=i; l=0;
- for (j=2; j<=N; j=j*2) {
- l+=(N/j)*(k%2); k=k/2;
- }
- if (l>i) {
- t=x[i];
- x[i]=x[l];
- x[l]=t;
- }
- }
- for (i=0; i<N/2; i++) w[i]=complexd(cos(2*PI/N*i),sin(2*PI/N*i));
- s=1;
- for (i=0; i<mu; i++) { //fft by binary dividing
- for (j=0; j<N; j+=s*2) {
- for (k=0; k<s; k++) {
- t=x[j+k+s]*(w[k*N/s/2]);
- t1=x[j+k]+t;
- t2=x[j+k]-t;
- x[j+k]=t1;
- x[j+k+s]=t2;
- }
- }
- s*=2;
- }
- for (i=0; i<N; i++) {y[i][0]=x[i].real(); y[i][1]=x[i].imag();}
- delete w; //very important. If not, the system will lost memory
- delete x;
- }