实现
-
1.C语言自相关
123456789101112void (float *x,int N,float *y){int i,j;for(i=0;i<N;i++){y[N+i-1]=y[N-i-1]=0;for(j=0;j<N;j++)if((j-i>=0)) y[N+i-1]+=x[j]*x[j-i];y[N-i-1]=y[N+i-1];}} -
2.C语言互相关
12345678910void xcorr(float *x,float *y,int N,float *z){int i,j;for(i=-N+1;i<N-1;i++){z[i+N-1]=0;for(j=0;j<N;j++)if((j+i>=0)&&(j+i)<N) z[i+N-1]+=x[j+i]*y[j];}} -
3.Fortran语言自相关
123456789101112131415161718c ------------------------------------------------------------c CC calculatingc ------------------------------------------------------------subroutine xcorr(x,y,n,z)real x(n),y(n),z(n+n-1)do i=-n+1,n-1z(i+n)=0do j=1,nif((j+i.ge.1).and.(j+i.le.n)) thenz(i+n)=z(i+n)+x(j+i)*y(j)end ifend doend doreturnend -
4.Fortran语言互相关
123456789101112131415161718192021222324c --------------c XX calculatingc --------------subroutine conv(x,n,y,m,z)real x(n),y(m),z(n+m-1)do i=0,n+m-2z(i+1)=0do j=0,m-1if(i-j.lt.0) thenexitend ifif((i-j.ge.0).and.(i-j.lt.n)) thenz(i+1)=z(i+1)+x(j+1)*y(i-j+1)elsecontinueend ifend doend doreturnend
近期评论