声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 3980|回复: 0

[Fortran] 直接按定义计算 的互相关函数

[复制链接]
发表于 2006-8-6 07:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
直接按定义计算x(n),y(n)的互相关函数若rxy(n),若y(n)=x(n)则求出的是自相关,x,y,r为复序列

主程序:
  1. C----------------------------------------------------------------------
  2. C main program HCORRE1:To test subroutine CORRE1
  3. C To compute the correlation of two complex sequences
  4. c To link subroutine CORRE1
  5. C----------------------------------------------------------------------
  6.         complex x(0:7),r(0:7)
  7.         data n/8/,lag/5/
  8.         do 10 i=0,7
  9. 10      x(i)=float(i+1)
  10.         call corre1(x,x,r,n,lag,Ierror)
  11.         if(ierror.ne.0)stop
  12.         write(*,*)'     Ierror=',Ierror
  13.         do 20 i=0,lag-1
  14.            write(*,*)i,r(i)
  15. 20      continue
  16.         stop
  17.         end
复制代码


子程序:
  1.       subroutine corre1(x,y,r,n,lag,ierror)
  2. C-----------------------------------------------------------------------
  3. C  Routine CORRE1:To estimate the biased cross-correlation function
  4. C  of complex arrays x and y. If y=x,then it is auto-correlation.
  5. c  input parameters:
  6. c     x  :n dimensioned complex array.
  7. c     y  :n dimensioned complex array.
  8. c     n  :the dimension of x and y.
  9. c     lag:the requested point numbers of correlation.
  10. c  output parameters:
  11. c     r  :lag dimensioned complex array, the correlation function is
  12. c         stored in r(0) to r(lag-1).
  13. c                                      in Chapter 1 and 11
  14. C-----------------------------------------------------------------------
  15.         complex x(0:n-1),y(0:n-1),r(0:lag-1)
  16.         Ierror=1
  17.         if(lag.gt.n) return
  18.         Ierror=0
  19.         do 30 k=0,lag-1
  20.            m=n-1-k
  21.            r(k)=0.0
  22.            do 10 j=0,m
  23.               r(k)=r(k)+y(j+k)*conjg(x(j))
  24. 10         continue
  25.            r(k)=r(k)/float(n)
  26. 30     continue
  27.        return
  28.        end
复制代码
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-25 13:56 , Processed in 0.069847 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表