VibInfo 发表于 2006-8-11 07:13

利用DFT的卷积性质求两个复序列的线性卷积

利用DFT的卷积性质求两个复序列的线性卷积

主程序:
C----------------------------------------------------------------------
C main program HCONVO2:To test subroutine CONVO2
c Please link subroutine CONVO2,SPLFFT
C----------------------------------------------------------------------
      complex h(0:7),x(0:7),y(0:7)
      data n1/4/,n2/2/,n/8/
      do 10 i=0,3
         h(i)=1.
         x(i)=i+1.
10      continue
      h(0)=1.
      h(1)=1.
      x(0)=1.
      x(1)=2.
      x(2)=3.
      x(3)=4.
      call convo2(x,h,y,n1,n2,n)
      do 20 k=0,n1+n2-2
20      write(*,*)k,real(y(k))
      stop
      end

子程序:
      subroutine convo2(x,h,y,n1,n2,n)
c----------------------------------------------------------------------
cRoutine CONVO2: To Compute the Convolution of x(i) and h(i) by DFT.
cx(i),i=0,...,n1-1; h(n),i=0,...,n2-1,But the dimension n of x,h,y
c       must be >=(n1+n2-1) and be the power of 2 ;
c input parameters:
c x( ):n dimensioned real array,signal data is stored in x(0) to x(n1-1).
c h( ):n dimensioned real array,impuls response is stored in h(0) to h(n2-1).
c output parameters:
c y( ):n dimensioned real array, y(i)=x(i)*h(i),i=0,...n-1.
c Notes:
c   n must be a power of 2.
c                                    in chapter 3
c----------------------------------------------------------------------
      complex x(0:n-1),y(0:n-1),h(0:n-1)
      do 10 i=1,16
         nn=2**i
         if(n.eq.nn) go to 20
10       continue
      write(*,*)'N is not a power of 2'
      return
20      do 30 i=n1,n-1
30          x(i)=0.
      do 40 i=n2,n-1
40         h(i)=0.
      call splfft(x,n,-1)
      call splfft(h,n,-1)
      do 50 k=0,n-1
50         y(k)=x(k)*h(k)
      call splfft(y,n,1)
      return
      end

[ 本帖最后由 VibInfo 于 2006-8-11 07:17 编辑 ]
页: [1]
查看完整版本: 利用DFT的卷积性质求两个复序列的线性卷积