6 #define WITHOUT_PIVOTING 0
7 #define WITH_PIVOTING 1
19 #define AA(i, j) aa[(m1 + m2 + 1) * (i) + (j)]
21 #define AAORIG(i, j) aaorig[(m1 + m2 + 1) * (i) + (j)]
23 #define AAL(i, j) aal[m1 * (i) + (j)]
25 void tridiag(
int n,
double *
a,
double *
b,
double *c,
double *
r,
double *u,
27 int j, m1, m2, mm, *index;
28 double bet, *gam, *aa, *aaorig, *aal, d;
33 static char dbmsname[] =
"tridiag";
39 fprintf(stderr,
"**error:%s, n = %d\n", dbmsname, n);
45 gam = (
double *)malloc(n *
sizeof(
double));
49 "**error:%s,b[0] = 0\n"
50 "Rewrite equations as a set of order n-1, with u[1]\n"
51 "trivially eliminated\n",
57 for (
j = 1;
j < n;
j++) {
58 gam[
j] = c[
j - 1] / bet;
59 bet =
b[
j] -
a[
j] * gam[
j];
65 fprintf(stderr,
"Warning: tridiag(): retrying with pivoting.\n");
71 u[
j] = (
r[
j] -
a[
j] * u[
j - 1]) / bet;
75 for (
j = n - 2;
j >= 0;
j--) {
76 u[
j] -= gam[
j + 1] * u[
j + 1];
91 aa = (
double *)malloc(n * (m1 + m2 + 1) *
sizeof(double));
92 aaorig = (
double *)malloc(n * (m1 + m2 + 1) *
sizeof(double));
93 aal = (
double *)malloc(n * m1 *
sizeof(
double));
94 index = (
int *)malloc(n *
sizeof(
int));
99 for (
j = 0;
j < n;
j++) {
112 for (
j = 0;
j < n;
j++) {
133 fprintf(stderr,
"**error:%s, unrecognized pivot_type=%d\n", dbmsname,
void band_back_sub(int n, int m1, int m2, double *a, double *al, int *index, double *b)
void band_decomp(int n, int m1, int m2, double *a, double *al, int *index, double *d)
void band_improve(int n, int m1, int m2, double *aorig, double *a, double *al, int *index, double *b, double *x)
void tridiag(int n, double *a, double *b, double *c, double *r, double *u, int pivot_type)