All-select main element Gaussian decision algorithm

xiaoxiao2021-03-06  14

/ * All-selected main element Gaussi decoction algorithm, solve linear equation A * x = b by kingwei 2005.2.27 * / # include #include #define EPS 1E-11 # define max_dim 20int Gausslequation (Double X [], INT DIM, DOUBLE A [], Double B []) {Int MaxColpos [Max_DIM], MaxRowpos; Double Maxelem, Abselem, Temp; Int K, I, J, STATUS = 1; For (k = 0; k EPS) RETURN 0; for (i = k; i

A [I] [MaxColpos [K]] = Temp;}} TEMP = a [k] [k]; for (j = k; j = 0; I -) {TEMP = 0.0; for (j = DIM-1; J> i; j -) TEMP = X [J] * a [i] [j]; x [i] = B [i] -Temp;} for (i = DIM-1; I> = 0; I -) IF (MaxColpos [i]! = i) {temp = x [i]; x [i] = x [ MaxColpos [I]]; x [MaxColpos [i]] = Temp;} Return status;} int} int} [max_dim], double b [] d], double b []) {INT I, J; IF (Scanf ("% D", DIM) == EOF) RETURN 0; for (i = 0; i <* DIM; i ) {for (j = 0; j <* Dim; J ) S Canf ("% lf", & a [i] [j]); scanf ("% lf", & b [i]);} return 1;} void displayRoot (double x [】, int Dim) {INT i; for (i = 0; i

转载请注明原文地址:https://www.9cbs.com/read-50006.html

New Post(0)