vanded.c

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

C
38
字号
/* Copyright (c) Colorado School of Mines, 1990./* All rights reserved.                       *//*FUNCTION:  solve Vandermonde system of equations Vx=b (double version)PARAMETERS:n			i dimension of systemv			i array of 2nd row of Vandermonde matrix (1st row is all ones)b			i array of right-hand-side column vectorx			o array of solution column vectorNOTES:The arrays b and x may be equivalenced.Adapted from Algorithm 5.6-2 in Golub, G. H., and Van Loan, C. F., 1983,Matrix Computations, John-Hopkins University Press.AUTHOR:  Dave Hale, Colorado School of Mines, 06/02/89*/void vanded (int n, double v[], double b[], double x[]){	int i,j;	for (i=0; i<n; i++)		x[i] = b[i];	for (i=0; i<n-1; i++)		for (j=n-1; j>i; j--)			x[j] -= v[i]*x[j-1];	for (i=n-1; i>0; i--) {		for (j=i; j<n; j++)			x[j] /= (v[j]-v[j-i]);		for (j=i; j<n; j++)			x[j-1] -= x[j];	}}

⌨️ 快捷键说明

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