35 double *c = 0, *d = 0, *Aj, *Ak, *Inversek;
36 double Temp, Scale, Sum;
37 int i, j, k, Success = 0;
40 if(!(c = (
double *)
Malloc(
sizeof(
double)*N))
41 || !(d = (
double *)
Malloc(
sizeof(
double)*N)))
44 for(k = 0, Ak = AData; k < N - 1; k++, Ak += N)
48 for(i = k; i < N; i++)
49 if((Temp = fabs(Ak[i])) > Scale)
58 for(i = k; i < N; i++)
61 for(Sum = 0.0, i = k; i < N; i++)
64 Temp = (Ak[k] >= 0.0)? sqrt(Sum) : -sqrt(Sum);
69 for(j = k + 1, Aj = Ak + N; j < N; j++, Aj += N)
71 for(Scale = 0.0, i = k; i < N; i++)
72 Scale += Ak[i] * Aj[i];
76 for(i = k; i < N; i++)
89 for(k = 0, Inversek = InverseData; k < N; k++, Inversek += N)
91 for(i = 0; i < N; i++)
92 Inversek[i] = -AData[k]*AData[i]/c[0];
96 for(j = 1, Aj = AData + N; j < N-1; j++, Aj += N)
98 for(Scale = 0.0, i = j; i < N; i++)
99 Scale += Aj[i]*Inversek[i];
103 for(i = j; i < N; i++)
104 Inversek[i] -= Scale*Aj[i];
107 Inversek[j] /= d[N-1];
109 for(i = N - 2; i >= 0; i--)
111 for(Sum = 0.0, j = i + 1, Aj = AData + N*(i + 1); j < N; j++, Aj += N)
112 Sum += Aj[i]*Inversek[j];
114 Inversek[i] = (Inversek[i] - Sum)/d[i];