00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int cgtt01_(integer *n, complex *dl, complex *d__, complex *
00017 du, complex *dlf, complex *df, complex *duf, complex *du2, integer *
00018 ipiv, complex *work, integer *ldwork, real *rwork, real *resid)
00019 {
00020
00021 integer work_dim1, work_offset, i__1, i__2, i__3, i__4;
00022 complex q__1;
00023
00024
00025 integer i__, j;
00026 complex li;
00027 integer ip;
00028 real eps, anorm;
00029 integer lastj;
00030 extern int cswap_(integer *, complex *, integer *,
00031 complex *, integer *), caxpy_(integer *, complex *, complex *,
00032 integer *, complex *, integer *);
00033 extern doublereal slamch_(char *), clangt_(char *, integer *,
00034 complex *, complex *, complex *), clanhs_(char *, integer
00035 *, complex *, integer *, real *);
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.f;
00133 return 0;
00134 }
00135
00136 eps = slamch_("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 i__3 = i__ + j * work_dim1;
00145 work[i__3].r = 0.f, work[i__3].i = 0.f;
00146
00147 }
00148
00149 }
00150 i__1 = *n;
00151 for (i__ = 1; i__ <= i__1; ++i__) {
00152 if (i__ == 1) {
00153 i__2 = i__ + i__ * work_dim1;
00154 i__3 = i__;
00155 work[i__2].r = df[i__3].r, work[i__2].i = df[i__3].i;
00156 if (*n >= 2) {
00157 i__2 = i__ + (i__ + 1) * work_dim1;
00158 i__3 = i__;
00159 work[i__2].r = duf[i__3].r, work[i__2].i = duf[i__3].i;
00160 }
00161 if (*n >= 3) {
00162 i__2 = i__ + (i__ + 2) * work_dim1;
00163 i__3 = i__;
00164 work[i__2].r = du2[i__3].r, work[i__2].i = du2[i__3].i;
00165 }
00166 } else if (i__ == *n) {
00167 i__2 = i__ + i__ * work_dim1;
00168 i__3 = i__;
00169 work[i__2].r = df[i__3].r, work[i__2].i = df[i__3].i;
00170 } else {
00171 i__2 = i__ + i__ * work_dim1;
00172 i__3 = i__;
00173 work[i__2].r = df[i__3].r, work[i__2].i = df[i__3].i;
00174 i__2 = i__ + (i__ + 1) * work_dim1;
00175 i__3 = i__;
00176 work[i__2].r = duf[i__3].r, work[i__2].i = duf[i__3].i;
00177 if (i__ < *n - 1) {
00178 i__2 = i__ + (i__ + 2) * work_dim1;
00179 i__3 = i__;
00180 work[i__2].r = du2[i__3].r, work[i__2].i = du2[i__3].i;
00181 }
00182 }
00183
00184 }
00185
00186
00187
00188 lastj = *n;
00189 for (i__ = *n - 1; i__ >= 1; --i__) {
00190 i__1 = i__;
00191 li.r = dlf[i__1].r, li.i = dlf[i__1].i;
00192 i__1 = lastj - i__ + 1;
00193 caxpy_(&i__1, &li, &work[i__ + i__ * work_dim1], ldwork, &work[i__ +
00194 1 + i__ * work_dim1], ldwork);
00195 ip = ipiv[i__];
00196 if (ip == i__) {
00197
00198 i__1 = i__ + 2;
00199 lastj = min(i__1,*n);
00200 } else {
00201 i__1 = lastj - i__ + 1;
00202 cswap_(&i__1, &work[i__ + i__ * work_dim1], ldwork, &work[i__ + 1
00203 + i__ * work_dim1], ldwork);
00204 }
00205
00206 }
00207
00208
00209
00210 i__1 = work_dim1 + 1;
00211 i__2 = work_dim1 + 1;
00212 q__1.r = work[i__2].r - d__[1].r, q__1.i = work[i__2].i - d__[1].i;
00213 work[i__1].r = q__1.r, work[i__1].i = q__1.i;
00214 if (*n > 1) {
00215 i__1 = (work_dim1 << 1) + 1;
00216 i__2 = (work_dim1 << 1) + 1;
00217 q__1.r = work[i__2].r - du[1].r, q__1.i = work[i__2].i - du[1].i;
00218 work[i__1].r = q__1.r, work[i__1].i = q__1.i;
00219 i__1 = *n + (*n - 1) * work_dim1;
00220 i__2 = *n + (*n - 1) * work_dim1;
00221 i__3 = *n - 1;
00222 q__1.r = work[i__2].r - dl[i__3].r, q__1.i = work[i__2].i - dl[i__3]
00223 .i;
00224 work[i__1].r = q__1.r, work[i__1].i = q__1.i;
00225 i__1 = *n + *n * work_dim1;
00226 i__2 = *n + *n * work_dim1;
00227 i__3 = *n;
00228 q__1.r = work[i__2].r - d__[i__3].r, q__1.i = work[i__2].i - d__[i__3]
00229 .i;
00230 work[i__1].r = q__1.r, work[i__1].i = q__1.i;
00231 i__1 = *n - 1;
00232 for (i__ = 2; i__ <= i__1; ++i__) {
00233 i__2 = i__ + (i__ - 1) * work_dim1;
00234 i__3 = i__ + (i__ - 1) * work_dim1;
00235 i__4 = i__ - 1;
00236 q__1.r = work[i__3].r - dl[i__4].r, q__1.i = work[i__3].i - dl[
00237 i__4].i;
00238 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00239 i__2 = i__ + i__ * work_dim1;
00240 i__3 = i__ + i__ * work_dim1;
00241 i__4 = i__;
00242 q__1.r = work[i__3].r - d__[i__4].r, q__1.i = work[i__3].i - d__[
00243 i__4].i;
00244 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00245 i__2 = i__ + (i__ + 1) * work_dim1;
00246 i__3 = i__ + (i__ + 1) * work_dim1;
00247 i__4 = i__;
00248 q__1.r = work[i__3].r - du[i__4].r, q__1.i = work[i__3].i - du[
00249 i__4].i;
00250 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00251
00252 }
00253 }
00254
00255
00256
00257 anorm = clangt_("1", n, &dl[1], &d__[1], &du[1]);
00258
00259
00260
00261
00262 *resid = clanhs_("1", n, &work[work_offset], ldwork, &rwork[1])
00263 ;
00264
00265
00266
00267 if (anorm <= 0.f) {
00268 if (*resid != 0.f) {
00269 *resid = 1.f / eps;
00270 }
00271 } else {
00272 *resid = *resid / anorm / eps;
00273 }
00274
00275 return 0;
00276
00277
00278
00279 }