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

📄 fft4g.f

📁 This is a package to calculate Discrete Fourier/Cosine/Sine Transforms of 1-dimensional sequences of
💻 F
📖 第 1 页 / 共 3 页
字号:
! Fast Fourier/Cosine/Sine Transform!     dimension   :one!     data length :power of 2!     decimation  :frequency!     radix       :4, 2!     data        :inplace!     table       :use! subroutines!     cdft: Complex Discrete Fourier Transform!     rdft: Real Discrete Fourier Transform!     ddct: Discrete Cosine Transform!     ddst: Discrete Sine Transform!     dfct: Cosine Transform of RDFT (Real Symmetric DFT)!     dfst: Sine Transform of RDFT (Real Anti-symmetric DFT)!!! -------- Complex DFT (Discrete Fourier Transform) --------!     [definition]!         <case1>!             X(k) = sum_j=0^n-1 x(j)*exp(2*pi*i*j*k/n), 0<=k<n!         <case2>!             X(k) = sum_j=0^n-1 x(j)*exp(-2*pi*i*j*k/n), 0<=k<n!         (notes: sum_j=0^n-1 is a summation from j=0 to n-1)!     [usage]!         <case1>!             ip(0) = 0  ! first time only!             call cdft(2*n, 1, a, ip, w)!         <case2>!             ip(0) = 0  ! first time only!             call cdft(2*n, -1, a, ip, w)!     [parameters]!         2*n          :data length (integer)!                       n >= 1, n = power of 2!         a(0:2*n-1)   :input/output data (real*8)!                       input data!                           a(2*j) = Re(x(j)), !                           a(2*j+1) = Im(x(j)), 0<=j<n!                       output data!                           a(2*k) = Re(X(k)), !                           a(2*k+1) = Im(X(k)), 0<=k<n!         ip(0:*)      :work area for bit reversal (integer)!                       length of ip >= 2+sqrt(n)!                       strictly, !                       length of ip >= !                           2+2**(int(log(n+0.5)/log(2.0))/2).!                       ip(0),ip(1) are pointers of the cos/sin table.!         w(0:n/2-1)   :cos/sin table (real*8)!                       w(),ip() are initialized if ip(0) = 0.!     [remark]!         Inverse of !             call cdft(2*n, -1, a, ip, w)!         is !             call cdft(2*n, 1, a, ip, w)!             do j = 0, 2 * n - 1!                 a(j) = a(j) / n!             end do!         .!!! -------- Real DFT / Inverse of Real DFT --------!     [definition]!         <case1> RDFT!             R(k) = sum_j=0^n-1 a(j)*cos(2*pi*j*k/n), 0<=k<=n/2!             I(k) = sum_j=0^n-1 a(j)*sin(2*pi*j*k/n), 0<k<n/2!         <case2> IRDFT (excluding scale)!             a(k) = (R(0) + R(n/2)*cos(pi*k))/2 + !                    sum_j=1^n/2-1 R(j)*cos(2*pi*j*k/n) + !                    sum_j=1^n/2-1 I(j)*sin(2*pi*j*k/n), 0<=k<n!     [usage]!         <case1>!             ip(0) = 0  ! first time only!             call rdft(n, 1, a, ip, w)!         <case2>!             ip(0) = 0  ! first time only!             call rdft(n, -1, a, ip, w)!     [parameters]!         n            :data length (integer)!                       n >= 2, n = power of 2!         a(0:n-1)     :input/output data (real*8)!                       <case1>!                           output data!                               a(2*k) = R(k), 0<=k<n/2!                               a(2*k+1) = I(k), 0<k<n/2!                               a(1) = R(n/2)!                       <case2>!                           input data!                               a(2*j) = R(j), 0<=j<n/2!                               a(2*j+1) = I(j), 0<j<n/2!                               a(1) = R(n/2)!         ip(0:*)      :work area for bit reversal (integer)!                       length of ip >= 2+sqrt(n/2)!                       strictly, !                       length of ip >= !                           2+2**(int(log(n/2+0.5)/log(2.0))/2).!                       ip(0),ip(1) are pointers of the cos/sin table.!         w(0:n/2-1)   :cos/sin table (real*8)!                       w(),ip() are initialized if ip(0) = 0.!     [remark]!         Inverse of !             call rdft(n, 1, a, ip, w)!         is !             call rdft(n, -1, a, ip, w)!             do j = 0, n - 1!                 a(j) = a(j) * 2 / n!             end do!         .!!! -------- DCT (Discrete Cosine Transform) / Inverse of DCT --------!     [definition]!         <case1> IDCT (excluding scale)!             C(k) = sum_j=0^n-1 a(j)*cos(pi*j*(k+1/2)/n), 0<=k<n!         <case2> DCT!             C(k) = sum_j=0^n-1 a(j)*cos(pi*(j+1/2)*k/n), 0<=k<n!     [usage]!         <case1>!             ip(0) = 0  ! first time only!             call ddct(n, 1, a, ip, w)!         <case2>!             ip(0) = 0  ! first time only!             call ddct(n, -1, a, ip, w)!     [parameters]!         n            :data length (integer)!                       n >= 2, n = power of 2!         a(0:n-1)     :input/output data (real*8)!                       output data!                           a(k) = C(k), 0<=k<n!         ip(0:*)      :work area for bit reversal (integer)!                       length of ip >= 2+sqrt(n/2)!                       strictly, !                       length of ip >= !                           2+2**(int(log(n/2+0.5)/log(2.0))/2).!                       ip(0),ip(1) are pointers of the cos/sin table.!         w(0:n*5/4-1) :cos/sin table (real*8)!                       w(),ip() are initialized if ip(0) = 0.!     [remark]!         Inverse of !             call ddct(n, -1, a, ip, w)!         is !             a(0) = a(0) / 2!             call ddct(n, 1, a, ip, w)!             do j = 0, n - 1!                 a(j) = a(j) * 2 / n!             end do!         .!!! -------- DST (Discrete Sine Transform) / Inverse of DST --------!     [definition]!         <case1> IDST (excluding scale)!             S(k) = sum_j=1^n A(j)*sin(pi*j*(k+1/2)/n), 0<=k<n!         <case2> DST!             S(k) = sum_j=0^n-1 a(j)*sin(pi*(j+1/2)*k/n), 0<k<=n!     [usage]!         <case1>!             ip(0) = 0  ! first time only!             call ddst(n, 1, a, ip, w)!         <case2>!             ip(0) = 0  ! first time only!             call ddst(n, -1, a, ip, w)!     [parameters]!         n            :data length (integer)!                       n >= 2, n = power of 2!         a(0:n-1)     :input/output data (real*8)!                       <case1>!                           input data!                               a(j) = A(j), 0<j<n!                               a(0) = A(n)!                           output data!                               a(k) = S(k), 0<=k<n!                       <case2>!                           output data!                               a(k) = S(k), 0<k<n!                               a(0) = S(n)!         ip(0:*)      :work area for bit reversal (integer)!                       length of ip >= 2+sqrt(n/2)!                       strictly, !                       length of ip >= !                           2+2**(int(log(n/2+0.5)/log(2.0))/2).!                       ip(0),ip(1) are pointers of the cos/sin table.!         w(0:n*5/4-1) :cos/sin table (real*8)!                       w(),ip() are initialized if ip(0) = 0.!     [remark]!         Inverse of !             call ddst(n, -1, a, ip, w)!         is !             a(0) = a(0) / 2!             call ddst(n, 1, a, ip, w)!             do j = 0, n - 1!                 a(j) = a(j) * 2 / n!             end do!         .!!! -------- Cosine Transform of RDFT (Real Symmetric DFT) --------!     [definition]!         C(k) = sum_j=0^n a(j)*cos(pi*j*k/n), 0<=k<=n!     [usage]!         ip(0) = 0  ! first time only!         call dfct(n, a, t, ip, w)!     [parameters]!         n            :data length - 1 (integer)!                       n >= 2, n = power of 2!         a(0:n)       :input/output data (real*8)!                       output data!                           a(k) = C(k), 0<=k<=n!         t(0:n/2)     :work area (real*8)!         ip(0:*)      :work area for bit reversal (integer)!                       length of ip >= 2+sqrt(n/4)!                       strictly, !                       length of ip >= !                           2+2**(int(log(n/4+0.5)/log(2.0))/2).!                       ip(0),ip(1) are pointers of the cos/sin table.!         w(0:n*5/8-1) :cos/sin table (real*8)!                       w(),ip() are initialized if ip(0) = 0.!     [remark]!         Inverse of !             a(0) = a(0) / 2!             a(n) = a(n) / 2!             call dfct(n, a, t, ip, w)!         is !             a(0) = a(0) / 2!             a(n) = a(n) / 2!             call dfct(n, a, t, ip, w)!             do j = 0, n!                 a(j) = a(j) * 2 / n!             end do!         .!!! -------- Sine Transform of RDFT (Real Anti-symmetric DFT) --------!     [definition]!         S(k) = sum_j=1^n-1 a(j)*sin(pi*j*k/n), 0<k<n!     [usage]!         ip(0) = 0  ! first time only!         call dfst(n, a, t, ip, w)!     [parameters]!         n            :data length + 1 (integer)!                       n >= 2, n = power of 2!         a(0:n-1)     :input/output data (real*8)!                       output data!                           a(k) = S(k), 0<k<n!                       (a(0) is used for work area)!         t(0:n/2-1)   :work area (real*8)!         ip(0:*)      :work area for bit reversal (integer)!                       length of ip >= 2+sqrt(n/4)!                       strictly, !                       length of ip >= !                           2+2**(int(log(n/4+0.5)/log(2.0))/2).!                       ip(0),ip(1) are pointers of the cos/sin table.!         w(0:n*5/8-1) :cos/sin table (real*8)!                       w(),ip() are initialized if ip(0) = 0.!     [remark]!         Inverse of !             call dfst(n, a, t, ip, w)!         is !             call dfst(n, a, t, ip, w)!             do j = 1, n - 1!                 a(j) = a(j) * 2 / n!             end do!         .!!! Appendix :!     The cos/sin table is recalculated when the larger table required.!     w() and ip() are compatible with all routines.!!      subroutine cdft(n, isgn, a, ip, w)      integer n, isgn, ip(0 : *)      real*8 a(0 : n - 1), w(0 : *)      if (n .gt. 4 * ip(0)) then          call makewt(n / 4, ip, w)      end if      if (n .gt. 4) then          if (isgn .ge. 0) then              call bitrv2(n, ip(2), a)              call cftfsub(n, a, w)          else              call bitrv2conj(n, ip(2), a)              call cftbsub(n, a, w)          end if      else if (n .eq. 4) then          call cftfsub(n, a, w)      end if      end!      subroutine rdft(n, isgn, a, ip, w)      integer n, isgn, ip(0 : *), nw, nc      real*8 a(0 : n - 1), w(0 : *), xi      nw = ip(0)      if (n .gt. 4 * nw) then          nw = n / 4          call makewt(nw, ip, w)      end if      nc = ip(1)      if (n .gt. 4 * nc) then          nc = n / 4          call makect(nc, ip, w(nw))      end if      if (isgn .ge. 0) then          if (n .gt. 4) then              call bitrv2(n, ip(2), a)              call cftfsub(n, a, w)              call rftfsub(n, a, nc, w(nw))          else if (n .eq. 4) then              call cftfsub(n, a, w)          end if          xi = a(0) - a(1)          a(0) = a(0) + a(1)          a(1) = xi      else          a(1) = 0.5d0 * (a(0) - a(1))          a(0) = a(0) - a(1)          if (n .gt. 4) then              call rftbsub(n, a, nc, w(nw))              call bitrv2(n, ip(2), a)              call cftbsub(n, a, w)          else if (n .eq. 4) then              call cftfsub(n, a, w)          end if      end if      end!      subroutine ddct(n, isgn, a, ip, w)      integer n, isgn, ip(0 : *), j, nw, nc      real*8 a(0 : n - 1), w(0 : *), xr      nw = ip(0)      if (n .gt. 4 * nw) then          nw = n / 4          call makewt(nw, ip, w)      end if      nc = ip(1)      if (n .gt. nc) then          nc = n          call makect(nc, ip, w(nw))      end if      if (isgn .lt. 0) then          xr = a(n - 1)          do j = n - 2, 2, -2              a(j + 1) = a(j) - a(j - 1)              a(j) = a(j) + a(j - 1)          end do          a(1) = a(0) - xr          a(0) = a(0) + xr          if (n .gt. 4) then              call rftbsub(n, a, nc, w(nw))              call bitrv2(n, ip(2), a)              call cftbsub(n, a, w)          else if (n .eq. 4) then              call cftfsub(n, a, w)          end if      end if      call dctsub(n, a, nc, w(nw))      if (isgn .ge. 0) then          if (n .gt. 4) then              call bitrv2(n, ip(2), a)              call cftfsub(n, a, w)              call rftfsub(n, a, nc, w(nw))          else if (n .eq. 4) then              call cftfsub(n, a, w)          end if          xr = a(0) - a(1)          a(0) = a(0) + a(1)          do j = 2, n - 2, 2              a(j - 1) = a(j) - a(j + 1)              a(j) = a(j) + a(j + 1)          end do          a(n - 1) = xr      end if      end!      subroutine ddst(n, isgn, a, ip, w)      integer n, isgn, ip(0 : *), j, nw, nc      real*8 a(0 : n - 1), w(0 : *), xr      nw = ip(0)      if (n .gt. 4 * nw) then          nw = n / 4          call makewt(nw, ip, w)      end if      nc = ip(1)      if (n .gt. nc) then          nc = n          call makect(nc, ip, w(nw))      end if      if (isgn .lt. 0) then          xr = a(n - 1)          do j = n - 2, 2, -2              a(j + 1) = -a(j) - a(j - 1)              a(j) = a(j) - a(j - 1)          end do          a(1) = a(0) + xr          a(0) = a(0) - xr          if (n .gt. 4) then              call rftbsub(n, a, nc, w(nw))              call bitrv2(n, ip(2), a)              call cftbsub(n, a, w)          else if (n .eq. 4) then              call cftfsub(n, a, w)          end if      end if      call dstsub(n, a, nc, w(nw))      if (isgn .ge. 0) then          if (n .gt. 4) then              call bitrv2(n, ip(2), a)              call cftfsub(n, a, w)              call rftfsub(n, a, nc, w(nw))          else if (n .eq. 4) then              call cftfsub(n, a, w)          end if          xr = a(0) - a(1)          a(0) = a(0) + a(1)          do j = 2, n - 2, 2              a(j - 1) = -a(j) - a(j + 1)

⌨️ 快捷键说明

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