⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fast fourier transform in c# (cooky-turkey) - adrian's tech blog - 博客园.htm

📁 c语言写的FFT变换源码,有多个版本,经测试,还比较好用
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0057)http://www.cnblogs.com/Dah/archive/2007/08/10/850904.html -->
<HTML><HEAD id=Head><TITLE>Fast Fourier Transform in C# (Cooky-Turkey) - Adrian's Tech Blog - 博客园</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META id=metaKeywords content=Fast,Fourier,Transform,in,C,Cooky,Turkey, 
name=keywords>
<META 
content=C#codesnippetbelowisanillustrationoftheCooky-Turkeyalgorithm,theperformancemaysuckwhenprocessinghugedatasets,butyoucanusearrays 
name=description><LINK id=CommondCss 
href="Fast Fourier Transform in C# (Cooky-Turkey) - Adrian's Tech Blog - 博客园.files/common.css" 
type=text/css rel=stylesheet><LINK id=MainCss 
href="Fast Fourier Transform in C# (Cooky-Turkey) - Adrian's Tech Blog - 博客园.files/style.css" 
type=text/css rel=stylesheet><LINK id=SecondaryCss 
href="Fast Fourier Transform in C# (Cooky-Turkey) - Adrian's Tech Blog - 博客园.files/customcss.css" 
type=text/css rel=stylesheet><LINK id=RSSLink title=RSS 
href="http://www.cnblogs.com/Dah/rss" type=application/rss+xml rel=alternate>
<SCRIPT 
src="Fast Fourier Transform in C# (Cooky-Turkey) - Adrian's Tech Blog - 博客园.files/common.js" 
type=text/javascript></SCRIPT>

<META content="MSHTML 6.00.2900.3354" name=GENERATOR></HEAD>
<BODY>
<FORM id=Form1 name=Form1 onsubmit="javascript:return WebForm_OnSubmit();" 
action=850904.html method=post>
<DIV><INPUT id=__EVENTTARGET type=hidden name=__EVENTTARGET> <INPUT 
id=__EVENTARGUMENT type=hidden name=__EVENTARGUMENT> <INPUT 
id="&#13;&#10;__VIEWSTATE" type=hidden name=__VIEWSTATE> </DIV>
<SCRIPT type=text/javascript>
//<![CDATA[
var theForm = document.forms['Form1'];
if (!theForm) {
    theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</SCRIPT>

<SCRIPT 
src="Fast Fourier Transform in C# (Cooky-Turkey) - Adrian's Tech Blog - 博客园.files/WebResource.axd" 
type=text/javascript></SCRIPT>

<SCRIPT language=JavaScript>
									function ctlent(evt,id)
											{
												if(evt.ctrlKey && evt.keyCode == 13)
												{	
													try
													{
														TempSave(id);
													}
													catch(ex)
													{
													}
													finally
													{
													    __doPostBack('AjaxHolder$PostComment$btnSubmit','')
													}
												}
		
												}</SCRIPT>

<SCRIPT language=JavaScript>function SetReplyAuhor(author){document.getElementById('AjaxHolder_PostComment_tbComment').value+="@"+author+"\n";document.getElementById('AjaxHolder_PostComment_tbComment').focus();return false}</SCRIPT>

<SCRIPT 
src="Fast Fourier Transform in C# (Cooky-Turkey) - Adrian's Tech Blog - 博客园.files/ScriptResource.axd" 
type=text/javascript></SCRIPT>

<SCRIPT 
src="C:\Documents and Settings\406\桌面\c#_GDI\FFT\Fast Fourier Transform in C# (Cooky-Turkey) - Adrian's Tech Blog - 博客园.files\ScriptResource(1).axd" 
type=text/javascript></SCRIPT>

<SCRIPT 
src="C:\Documents and Settings\406\桌面\c#_GDI\FFT\Fast Fourier Transform in C# (Cooky-Turkey) - Adrian's Tech Blog - 博客园.files\ScriptResource(2).axd" 
type=text/javascript></SCRIPT>

<SCRIPT 
src="Fast Fourier Transform in C# (Cooky-Turkey) - Adrian's Tech Blog - 博客园.files/js" 
type=text/javascript></SCRIPT>

<SCRIPT type=text/javascript>
//<![CDATA[
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
//]]>
</SCRIPT>

<DIV style="LEFT: 300px; POSITION: absolute; TOP: 20px"></DIV>
<DIV id=container>
<DIV id=header>
<DIV id=top>
<H1><A class=weblogtitle id=Header1_HeaderTitle 
href="http://www.cnblogs.com/Dah/">Adrian's Tech Blog</A></H1>
<P></P></DIV>
<DIV id=navstats></DIV>
<DIV id=nav>
<UL>
  <LI><A id=Header1_MyLinks1_HomeLink href="http://www.cnblogs.com/">博客园</A> 
  <LI><A id=Header1_MyLinks1_MyHomeLink 
  href="http://www.cnblogs.com/Dah/">首页</A> 
  <LI>
  <LI><A id=Header1_MyLinks1_ContactLink accessKey=9 
  href="http://www.cnblogs.com/Dah/contact.aspx?id=1">联系</A> 
  <LI><A id=Header1_MyLinks1_Admin 
  href="http://www.cnblogs.com/Dah/admin/EditPosts.aspx">管理</A> </LI></UL><SPAN><A 
id=Header1_MyLinks1_XMLLink href="http://www.cnblogs.com/Dah/rss"><IMG 
style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" 
alt=订阅 
src="Fast Fourier Transform in C# (Cooky-Turkey) - Adrian's Tech Blog - 博客园.files/xml.gif"></A>&nbsp;<A 
id=Header1_MyLinks1_Syndication 
href="http://www.cnblogs.com/Dah/rss">订阅</A></SPAN> </DIV></DIV>
<DIV class=clr></DIV>
<DIV id=content>
<SCRIPT type=text/javascript>
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('AjaxHolder$scriptmanager1', document.getElementById('Form1'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tAjaxHolder$UpdatePanel1'], [], [], 90);
//]]>
</SCRIPT>

<DIV class=post>
<DIV class=posthead>
<H2><A class=singleposttitle id=AjaxHolder_ctl01_TitleUrl 
href="http://www.cnblogs.com/Dah/archive/2007/08/10/850904.html">Fast Fourier 
Transform in C# (Cooky-Turkey)</A> </H2></DIV>
<DIV class=postbody>C# code snippet below is an illustration of the Cooky-Turkey 
algorithm, the performance may suck when processing huge datasets, but you can 
use arrays of double instead of arrays of complex number structure to reduce the 
performance impact by object initializations and method invocations(overloaded 
operators).<BR>Furthermore, you can use "Butterfly" computation(<A 
href="http://www.cmlab.csie.ntu.edu.tw/cml/dsp/training/coding/transform/fft.html">http://www.cmlab.csie.ntu.edu.tw/cml/dsp/training/coding/transform/fft.html</A>) 
to gain a much better performance.<BR><BR>
<DIV 
style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><SPAN 
style="COLOR: #0000ff">private</SPAN><SPAN 
style="COLOR: #000000">&nbsp;Complex[]&nbsp;FFT(Complex[]&nbsp;input,</SPAN><SPAN 
style="COLOR: #0000ff">bool</SPAN><SPAN 
style="COLOR: #000000">&nbsp;invert)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">if</SPAN><SPAN 
style="COLOR: #000000">&nbsp;(input.Length&nbsp;</SPAN><SPAN 
style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN 
style="COLOR: #000000">1</SPAN><SPAN 
style="COLOR: #000000">)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">return</SPAN><SPAN 
style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN 
style="COLOR: #000000">&nbsp;Complex[]&nbsp;{&nbsp;input[</SPAN><SPAN 
style="COLOR: #000000">0</SPAN><SPAN 
style="COLOR: #000000">]&nbsp;};<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">int</SPAN><SPAN 
style="COLOR: #000000">&nbsp;length&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN 
style="COLOR: #000000">&nbsp;input.Length;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">int</SPAN><SPAN 
style="COLOR: #000000">&nbsp;half&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN 
style="COLOR: #000000">&nbsp;length&nbsp;</SPAN><SPAN 
style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN 
style="COLOR: #000000">2</SPAN><SPAN 
style="COLOR: #000000">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;Complex[]&nbsp;result&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">new</SPAN><SPAN 
style="COLOR: #000000">&nbsp;Complex[length];<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">double</SPAN><SPAN 
style="COLOR: #000000">&nbsp;fac&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN 
style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">2.0</SPAN><SPAN 
style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN 
style="COLOR: #000000">&nbsp;Math.PI&nbsp;</SPAN><SPAN 
style="COLOR: #000000">/</SPAN><SPAN 
style="COLOR: #000000">&nbsp;length;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">if</SPAN><SPAN 
style="COLOR: #000000">&nbsp;(invert)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fac&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN 
style="COLOR: #000000">-</SPAN><SPAN 
style="COLOR: #000000">fac;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;Complex[]&nbsp;evens&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">new</SPAN><SPAN 
style="COLOR: #000000">&nbsp;Complex[half];<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">for</SPAN><SPAN 
style="COLOR: #000000">&nbsp;(</SPAN><SPAN 
style="COLOR: #0000ff">int</SPAN><SPAN 
style="COLOR: #000000">&nbsp;i&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN 
style="COLOR: #000000">0</SPAN><SPAN 
style="COLOR: #000000">;&nbsp;i&nbsp;</SPAN><SPAN 
style="COLOR: #000000">&lt;</SPAN><SPAN 
style="COLOR: #000000">&nbsp;half;&nbsp;i</SPAN><SPAN 
style="COLOR: #000000">++</SPAN><SPAN 
style="COLOR: #000000">)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;evens[i]&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN 
style="COLOR: #000000">&nbsp;input[</SPAN><SPAN 
style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN 
style="COLOR: #000000">*</SPAN><SPAN 
style="COLOR: #000000">&nbsp;i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;Complex[]&nbsp;evenResult&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN 
style="COLOR: #000000">&nbsp;FFT(evens,invert);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;Complex[]&nbsp;odds&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN 
style="COLOR: #000000">&nbsp;evens;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">for</SPAN><SPAN 
style="COLOR: #000000">&nbsp;(</SPAN><SPAN 
style="COLOR: #0000ff">int</SPAN><SPAN 
style="COLOR: #000000">&nbsp;i&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN 
style="COLOR: #000000">0</SPAN><SPAN 
style="COLOR: #000000">;&nbsp;i&nbsp;</SPAN><SPAN 
style="COLOR: #000000">&lt;</SPAN><SPAN 
style="COLOR: #000000">&nbsp;half;&nbsp;i</SPAN><SPAN 
style="COLOR: #000000">++</SPAN><SPAN 
style="COLOR: #000000">)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;odds[i]&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN 
style="COLOR: #000000">&nbsp;input[</SPAN><SPAN 
style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN 
style="COLOR: #000000">*</SPAN><SPAN 
style="COLOR: #000000">&nbsp;i&nbsp;</SPAN><SPAN 
style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN 
style="COLOR: #000000">1</SPAN><SPAN 
style="COLOR: #000000">];<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;Complex[]&nbsp;oddResult&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN 
style="COLOR: #000000">&nbsp;FFT(odds,invert);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">for</SPAN><SPAN 
style="COLOR: #000000">&nbsp;(</SPAN><SPAN 
style="COLOR: #0000ff">int</SPAN><SPAN 
style="COLOR: #000000">&nbsp;k&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -