20 #define asub(i,j) a[(i)*n + (j)]
23 void solve(
double *a,
double *b,
double *c,
int n)
25 double *asave, *csave;
26 double amax, dum, pivot;
27 register int i, ii, j;
28 register int k, m, mp;
29 register int istar, ip;
30 register int nm, nsq, t;
34 asave =
N_GNEW(nsq,
double);
37 for (i = 0; i < n; i++)
39 for (i = 0; i < nsq; i++)
43 for (i = 0; i < nm; i++) {
46 for (ii = i; ii < n; ii++) {
47 dum = fabs(
asub(ii, i));
57 for (j = i; j < n; j++) {
68 for (ii = ip; ii < n; ii++) {
69 pivot = a[ii * n + i] / a[i * n + i];
70 c[ii] = c[ii] - pivot * c[i];
71 for (j = 0; j < n; j++)
72 a[ii * n + j] = a[ii * n + j] - pivot * a[i * n + j];
76 if (fabs(a[n * n - 1]) < 1.e-10)
78 b[n - 1] = c[n - 1] / a[n * n - 1];
80 for (k = 0; k < nm; k++) {
84 for (j = mp; j < n; j++)
85 b[m] = b[m] - a[m * n + j] * b[j];
86 b[m] = b[m] / a[m * n + m];
89 for (i = 0; i < n; i++)
91 for (i = 0; i < nsq; i++)
97 printf(
"ill-conditioned\n");
void solve(double *, double *, double *, int)