stoepd.c

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

C
59
字号
/* Copyright (c) Colorado School of Mines, 1990./* All rights reserved.                       *//*FUNCTION:  solve a symmetric Toeplitz linear system of equations Rf=g for f(double version)PARAMETERS:n			i dimension of systemr			i array of top row of Toeplitz matrixg			i array of right-hand-side column vectorf			o array of solution (left-hand-side) column vectora			o array of solution to Ra=v (Claerbout, FGDP, p. 57)NOTES:This routine does NOT solve the case when the main diagonal is zero, itjust silently returns.The left column of the Toeplitz matrix is assumed to be equal to the toprow (as specified in r); i.e., the Toeplitz matrix is assumed symmetric.AUTHOR:  Dave Hale, Colorado School of Mines, 06/02/89*/void stoepd (int n, double r[], double g[], double f[], double a[]){	int i,j;	double v,e,c,w,bot;	if (r[0] == 0.0) return;	a[0] = 1.0;	v = r[0];	f[0] = g[0]/r[0];	for (j=1; j<n; j++) {				/* solve Ra=v as in Claerbout, FGDP, p. 57 */		a[j] = 0.0;		f[j] = 0.0;		for (i=0,e=0.0; i<j; i++)			e += a[i]*r[j-i];		c = e/v;		v -= c*e;		for (i=0; i<=j/2; i++) {			bot = a[j-i]-c*a[i];			a[i] -= c*a[j-i];			a[j-i] = bot;		}		/* use a and v above to get f[i], i = 0,1,2,...,j */		for (i=0,w=0.0; i<j; i++)			w += f[i]*r[j-i];		c = (w-g[j])/v;		for (i=0; i<=j; i++)			f[i] -= c*a[j-i];	}}

⌨️ 快捷键说明

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