00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int dgtt01_(integer *n, doublereal *dl, doublereal *d__,
00017 doublereal *du, doublereal *dlf, doublereal *df, doublereal *duf,
00018 doublereal *du2, integer *ipiv, doublereal *work, integer *ldwork,
00019 doublereal *rwork, doublereal *resid)
00020 {
00021
00022 integer work_dim1, work_offset, i__1, i__2;
00023
00024
00025 integer i__, j;
00026 doublereal li;
00027 integer ip;
00028 doublereal eps, anorm;
00029 integer lastj;
00030 extern int dswap_(integer *, doublereal *, integer *,
00031 doublereal *, integer *), daxpy_(integer *, doublereal *,
00032 doublereal *, integer *, doublereal *, integer *);
00033 extern doublereal dlamch_(char *), dlangt_(char *, integer *,
00034 doublereal *, doublereal *, doublereal *), dlanhs_(char *,
00035 integer *, doublereal *, integer *, doublereal *);
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 --dl;
00118 --d__;
00119 --du;
00120 --dlf;
00121 --df;
00122 --duf;
00123 --du2;
00124 --ipiv;
00125 work_dim1 = *ldwork;
00126 work_offset = 1 + work_dim1;
00127 work -= work_offset;
00128 --rwork;
00129
00130
00131 if (*n <= 0) {
00132 *resid = 0.;
00133 return 0;
00134 }
00135
00136 eps = dlamch_("Epsilon");
00137
00138
00139
00140 i__1 = *n;
00141 for (j = 1; j <= i__1; ++j) {
00142 i__2 = *n;
00143 for (i__ = 1; i__ <= i__2; ++i__) {
00144 work[i__ + j * work_dim1] = 0.;
00145
00146 }
00147
00148 }
00149 i__1 = *n;
00150 for (i__ = 1; i__ <= i__1; ++i__) {
00151 if (i__ == 1) {
00152 work[i__ + i__ * work_dim1] = df[i__];
00153 if (*n >= 2) {
00154 work[i__ + (i__ + 1) * work_dim1] = duf[i__];
00155 }
00156 if (*n >= 3) {
00157 work[i__ + (i__ + 2) * work_dim1] = du2[i__];
00158 }
00159 } else if (i__ == *n) {
00160 work[i__ + i__ * work_dim1] = df[i__];
00161 } else {
00162 work[i__ + i__ * work_dim1] = df[i__];
00163 work[i__ + (i__ + 1) * work_dim1] = duf[i__];
00164 if (i__ < *n - 1) {
00165 work[i__ + (i__ + 2) * work_dim1] = du2[i__];
00166 }
00167 }
00168
00169 }
00170
00171
00172
00173 lastj = *n;
00174 for (i__ = *n - 1; i__ >= 1; --i__) {
00175 li = dlf[i__];
00176 i__1 = lastj - i__ + 1;
00177 daxpy_(&i__1, &li, &work[i__ + i__ * work_dim1], ldwork, &work[i__ +
00178 1 + i__ * work_dim1], ldwork);
00179 ip = ipiv[i__];
00180 if (ip == i__) {
00181
00182 i__1 = i__ + 2;
00183 lastj = min(i__1,*n);
00184 } else {
00185 i__1 = lastj - i__ + 1;
00186 dswap_(&i__1, &work[i__ + i__ * work_dim1], ldwork, &work[i__ + 1
00187 + i__ * work_dim1], ldwork);
00188 }
00189
00190 }
00191
00192
00193
00194 work[work_dim1 + 1] -= d__[1];
00195 if (*n > 1) {
00196 work[(work_dim1 << 1) + 1] -= du[1];
00197 work[*n + (*n - 1) * work_dim1] -= dl[*n - 1];
00198 work[*n + *n * work_dim1] -= d__[*n];
00199 i__1 = *n - 1;
00200 for (i__ = 2; i__ <= i__1; ++i__) {
00201 work[i__ + (i__ - 1) * work_dim1] -= dl[i__ - 1];
00202 work[i__ + i__ * work_dim1] -= d__[i__];
00203 work[i__ + (i__ + 1) * work_dim1] -= du[i__];
00204
00205 }
00206 }
00207
00208
00209
00210 anorm = dlangt_("1", n, &dl[1], &d__[1], &du[1]);
00211
00212
00213
00214
00215 *resid = dlanhs_("1", n, &work[work_offset], ldwork, &rwork[1])
00216 ;
00217
00218
00219
00220 if (anorm <= 0.) {
00221 if (*resid != 0.) {
00222 *resid = 1. / eps;
00223 }
00224 } else {
00225 *resid = *resid / anorm / eps;
00226 }
00227
00228 return 0;
00229
00230
00231
00232 }