johhan 发表于 2006-4-11 10:09

[求助]哪位兄弟有Fortran 或 VB编写的FFT源程序及使用方法

哪位兄弟有Fortran 或 VB编写的FFT源程序及使用方法<BR><BR><BR>请分享一下,谢谢!!!!

风花雪月 发表于 2006-4-12 06:56

回复:(johhan)[求助]哪位兄弟有Fortran 或 VB编写的...

fortran的函数库里边不是有FFT的函数吗?<BR>

风花雪月 发表于 2006-4-12 06:57

回复:(johhan)[求助]哪位兄弟有Fortran 或 VB编写的...

FFT的VB实现- -Tag: FFT    VB                                          
<P>
<P>'***************************************************************<BR>'FFT0 数组下标以0开始FFT1 数组下标以1开始<BR>'AR() 数据实部         AI() 数据虚部<BR>'N 数据点数,为2的整数次幂<BR>'NI 变换方向 1为正变换,-1为反变换<BR>'***************************************************************<BR>Public Const Pi = 3.1415926</P>
<P>Public Sub FFT0(AR() As Double, AI() As Double, N As Integer, NI As Integer)<BR>    Dim I As Integer, J As Integer, K As Integer, L As Integer, M As Integer<BR>    Dim IP As Integer, LE As Integer<BR>    Dim L1 As Integer, N1 As Integer, N2 As Integer<BR>    Dim SN As Double, TR As Double, TI As Double, WR As Double, WI As Double<BR>    Dim UR As Double, UI As Double, US As Double<BR>    M = NTOM(N)<BR>    N2 = N / 2<BR>    N1 = N - 1<BR>    SN = NI<BR>    J = 1<BR>    For I = 1 To N1<BR>      If I &lt; J Then<BR>            TR = AR(J - 1)<BR>            AR(J - 1) = AR(I - 1)<BR>            AR(I - 1) = TR<BR>            TI = AI(J - 1)<BR>            AI(J - 1) = AI(I - 1)<BR>            AI(I - 1) = TI<BR>      End If<BR>      K = N2<BR>      While (K &lt; J)<BR>            J = J - K<BR>            K = K / 2<BR>      Wend<BR>      J = J + K<BR>    Next I<BR>    For L = 1 To M<BR>      LE = 2 ^ L<BR>      L1 = LE / 2<BR>      UR = 1#<BR>      UI = 0#<BR>      WR = Cos(Pi / L1)<BR>      WI = SN * Sin(Pi / L1)<BR>      For J = 1 To L1<BR>            For I = J To N Step LE<BR>                IP = I + L1<BR>                TR = AR(IP - 1) * UR - AI(IP - 1) * UI<BR>                TI = AI(IP - 1) * UR + AR(IP - 1) * UI<BR>                AR(IP - 1) = AR(I - 1) - TR<BR>                AI(IP - 1) = AI(I - 1) - TI<BR>                AR(I - 1) = AR(I - 1) + TR<BR>                AI(I - 1) = AI(I - 1) + TI<BR>            Next I<BR>            US = UR<BR>            UR = US * WR - UI * WI<BR>            UI = UI * WR + US * WI<BR>      Next J<BR>    Next L<BR>    If SN &lt;&gt; -1 Then<BR>      For I = 1 To N<BR>            AR(I - 1) = AR(I - 1) / N<BR>            AI(I - 1) = AI(I - 1) / N<BR>      Next I<BR>    End If<BR>End Sub</P>
<P>Public Sub FFT1(AR() As Double, AI() As Double, N As Integer, NI As Integer)<BR>    Dim I As Integer, J As Integer, K As Integer, L As Integer, M As Integer<BR>    Dim IP As Integer, LE As Integer<BR>    Dim L1 As Integer, N1 As Integer, N2 As Integer<BR>    Dim SN As Double, TR As Double, TI As Double, WR As Double, WI As Double<BR>    Dim UR As Double, UI As Double, US As Double<BR>    M = NTOM(N)<BR>    N2 = N / 2<BR>    N1 = N - 1<BR>    SN = NI<BR>    J = 1<BR>    For I = 1 To N1<BR>      If I &lt; J Then<BR>            TR = AR(J)<BR>            AR(J) = AR(I)<BR>            AR(I) = TR<BR>            TI = AI(J)<BR>            AI(J) = AI(I)<BR>            AI(I) = TI<BR>      End If<BR>      K = N2<BR>      While (K &lt; J)<BR>            J = J - K<BR>            K = K / 2<BR>      Wend<BR>      J = J + K<BR>    Next I<BR>    For L = 1 To M<BR>      LE = 2 ^ L<BR>      L1 = LE / 2<BR>      UR = 1#<BR>      UI = 0#<BR>      WR = Cos(Pi / L1)<BR>      WI = SN * Sin(Pi / L1)<BR>      For J = 1 To L1<BR>            For I = J To N Step LE<BR>                IP = I + L1<BR>                TR = AR(IP) * UR - AI(IP) * UI<BR>                TI = AI(IP) * UR + AR(IP) * UI<BR>                AR(IP) = AR(I) - TR<BR>                AI(IP) = AI(I) - TI<BR>                AR(I) = AR(I) + TR<BR>                AI(I) = AI(I) + TI<BR>            Next I<BR>            US = UR<BR>            UR = US * WR - UI * WI<BR>            UI = UI * WR + US * WI<BR>      Next J<BR>    Next L<BR>    If SN &lt;&gt; -1 Then<BR>      For I = 1 To N<BR>            AR(I) = AR(I) / N<BR>            AI(I) = AI(I) / N<BR>      Next I<BR>    End If<BR>End Sub</P>
<P>Private Function NTOM(N As Integer) As Integer<BR>    Dim ND As Double<BR>    ND = N<BR>    NTOM = 0<BR>    While (ND &gt; 1)<BR>      ND = ND / 2<BR>      NTOM = NTOM + 1<BR>    Wend<BR>End Function<BR><BR></P>
<P>Public Sub FFT(INr#(), INi#(), n%, Mm%, TT#, NPP%)</P>
<P>Dim FFTn1%, FFTn2%, FFTsn%, FFTj%, FFTi%, FFTip%, tmpR#, tmpI#, FFTk%, FFTL%, FFTLE#, FFTL1#, FFTus#, FFTur#, FFTui#, FFTwr#, FFTwi#<BR><BR>FFTn2 = n / 2<BR>FFTn1 = n - 1<BR>FFTsn = NPP<BR>FFTj = 1<BR><BR>For FFTi = 1 To FFTn1<BR>If (FFTi &gt;= FFTj) Then GoTo X25<BR>tmpR = INr(FFTj)<BR>INr(FFTj) = INr(FFTi)<BR>INr(FFTi) = tmpR<BR>tmpI = INi(FFTj)<BR>INi(FFTj) = INi(FFTi)<BR>INi(FFTi) = tmpI<BR>X25: FFTk = FFTn2<BR>X45: If (FFTk &gt;= FFTj) Then GoTo X35<BR>FFTj = FFTj - FFTk<BR>FFTk = FFTk / 2<BR>GoTo X45<BR>X35: FFTj = FFTj + FFTk<BR>Next FFTi<BR><BR><BR>For FFTL = 1 To Mm<BR>FFTLE = 2 ^ FFTL<BR>FFTL1 = FFTLE / 2<BR>FFTur = 1<BR>FFTui = 0<BR>FFTwr = Cos(3.1415926 / FFTL1)<BR>FFTwi = FFTsn * Sin(3.1415926 / FFTL1)<BR>For FFTj = 1 To FFTL1<BR><BR>For FFTi = FFTj To n Step FFTLE<BR>FFTip = FFTi + FFTL1<BR>tmpR = INr(FFTip) * FFTur - INi(FFTip) * FFTui<BR>tmpI = INi(FFTip) * FFTur + INr(FFTip) * FFTui<BR>INr(FFTip) = INr(FFTi) - tmpR<BR>INi(FFTip) = INi(FFTi) - tmpI<BR>INr(FFTi) = INr(FFTi) + tmpR<BR>INi(FFTi) = INi(FFTi) + tmpI<BR>Next FFTi<BR>FFTus = FFTur<BR>FFTur = FFTus * FFTwr - FFTui * FFTwi<BR>FFTui = FFTui * FFTwr + FFTus * FFTwi<BR>Next FFTj<BR>Next FFTL<BR>If (FFTsn = -1) Then<BR>For FFTi = 1 To n<BR>INr(FFTi) = INr(FFTi) * TT<BR>INi(FFTi) = INi(FFTi) * TT<BR>Next FFTi<BR>Else<BR>For FFTi = 1 To n<BR>INr(FFTi) = INr(FFTi) / n / TT<BR>INi(FFTi) = INi(FFTi) / n / TT<BR>Next FFTi<BR>End If</P>
<P>End Sub<BR></P>

johhan 发表于 2006-4-12 08:49

回复:(风花雪月)回复:(johhan)[求助]哪位兄弟有...

<DIV class=quote><B>以下是引用<I>风花雪月</I>在2006-4-12 6:56:06的发言:</B><BR>fortran的函数库里边不是有FFT的函数吗?<BR></DIV>
<br>请教风花雪月朋友,Fortran中的FFT如何调用呀??<BR><BR>另外,Fortran自带的IMSL里面估计也会有FFT算法的,请问如何使用???<BR><BR>谢谢!!

Jeydragon 发表于 2012-8-27 13:56

淡定淡定的的淡定淡定的的淡定淡定的的淡定淡定的的淡定淡定的的淡定淡定的的淡定淡定的的淡定淡定的的淡定淡定的的淡定淡定的的淡定淡定
页: [1]
查看完整版本: [求助]哪位兄弟有Fortran 或 VB编写的FFT源程序及使用方法