conv.c

来自「seismic software,very useful」· C语言 代码 · 共 41 行

C
41
字号
/* Copyright (c) Colorado School of Mines, 1990./* All rights reserved.                       *//*FUNCTION: compute z = x convolved with y; i.e.,           ifx+lx-1    z[i] =   sum    x[j]*y[i-j]  ;  i = ifz,...,ifz+lz-1            j=ifxPARAMETERS:lx			i length of x arrayifx			i sample index of first xx			i array to be convolved with yly			i length of y arrayify			i sample index of first yy			i array with which x is to be convolvedlz			i length of z arrayifz			i sample index of first zz			o array containing x convolved with yAUTHOR:  Dave Hale, Colorado School of Mines, 06/02/89MODIFIED:  Dave Hale, Colorado School of Mines, 03/01/90	Use dot products for faster performance on non-vector machines.*/void conv (int lx, int ifx, float x[], int ly, int ify, float y[], 	int lz, int ifz, float z[]){	int ilx=ifx+lx-1,ily=ify+ly-1,ilz=ifz+lz-1,i,j,jlow,jhigh;	float *xp=x-ifx,*yp=y-ify,*zp=z-ifz,sum;	for (i=ifz; i<=ilz; ++i) {		jlow = i-ily;  if (jlow<ifx) jlow = ifx;		jhigh = i-ify;  if (jhigh>ilx) jhigh = ilx;		for (j=jlow,sum=0.0; j<=jhigh; ++j)			sum += xp[j]*yp[i-j];		zp[i] = sum;	}}

⌨️ 快捷键说明

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