00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int sgtt01_(integer *n, real *dl, real *d__, real *du, real *
00017 dlf, real *df, real *duf, real *du2, integer *ipiv, real *work,
00018 integer *ldwork, real *rwork, real *resid)
00019 {
00020
00021 integer work_dim1, work_offset, i__1, i__2;
00022
00023
00024 integer i__, j;
00025 real li;
00026 integer ip;
00027 real eps, anorm;
00028 integer lastj;
00029 extern int sswap_(integer *, real *, integer *, real *,
00030 integer *), saxpy_(integer *, real *, real *, integer *, real *,
00031 integer *);
00032 extern doublereal slamch_(char *), slangt_(char *, integer *,
00033 real *, real *, real *), slanhs_(char *, integer *, real *
00034 , integer *, real *);
00035
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 --dl;
00117 --d__;
00118 --du;
00119 --dlf;
00120 --df;
00121 --duf;
00122 --du2;
00123 --ipiv;
00124 work_dim1 = *ldwork;
00125 work_offset = 1 + work_dim1;
00126 work -= work_offset;
00127 --rwork;
00128
00129
00130 if (*n <= 0) {
00131 *resid = 0.f;
00132 return 0;
00133 }
00134
00135 eps = slamch_("Epsilon");
00136
00137
00138
00139 i__1 = *n;
00140 for (j = 1; j <= i__1; ++j) {
00141 i__2 = *n;
00142 for (i__ = 1; i__ <= i__2; ++i__) {
00143 work[i__ + j * work_dim1] = 0.f;
00144
00145 }
00146
00147 }
00148 i__1 = *n;
00149 for (i__ = 1; i__ <= i__1; ++i__) {
00150 if (i__ == 1) {
00151 work[i__ + i__ * work_dim1] = df[i__];
00152 if (*n >= 2) {
00153 work[i__ + (i__ + 1) * work_dim1] = duf[i__];
00154 }
00155 if (*n >= 3) {
00156 work[i__ + (i__ + 2) * work_dim1] = du2[i__];
00157 }
00158 } else if (i__ == *n) {
00159 work[i__ + i__ * work_dim1] = df[i__];
00160 } else {
00161 work[i__ + i__ * work_dim1] = df[i__];
00162 work[i__ + (i__ + 1) * work_dim1] = duf[i__];
00163 if (i__ < *n - 1) {
00164 work[i__ + (i__ + 2) * work_dim1] = du2[i__];
00165 }
00166 }
00167
00168 }
00169
00170
00171
00172 lastj = *n;
00173 for (i__ = *n - 1; i__ >= 1; --i__) {
00174 li = dlf[i__];
00175 i__1 = lastj - i__ + 1;
00176 saxpy_(&i__1, &li, &work[i__ + i__ * work_dim1], ldwork, &work[i__ +
00177 1 + i__ * work_dim1], ldwork);
00178 ip = ipiv[i__];
00179 if (ip == i__) {
00180
00181 i__1 = i__ + 2;
00182 lastj = min(i__1,*n);
00183 } else {
00184 i__1 = lastj - i__ + 1;
00185 sswap_(&i__1, &work[i__ + i__ * work_dim1], ldwork, &work[i__ + 1
00186 + i__ * work_dim1], ldwork);
00187 }
00188
00189 }
00190
00191
00192
00193 work[work_dim1 + 1] -= d__[1];
00194 if (*n > 1) {
00195 work[(work_dim1 << 1) + 1] -= du[1];
00196 work[*n + (*n - 1) * work_dim1] -= dl[*n - 1];
00197 work[*n + *n * work_dim1] -= d__[*n];
00198 i__1 = *n - 1;
00199 for (i__ = 2; i__ <= i__1; ++i__) {
00200 work[i__ + (i__ - 1) * work_dim1] -= dl[i__ - 1];
00201 work[i__ + i__ * work_dim1] -= d__[i__];
00202 work[i__ + (i__ + 1) * work_dim1] -= du[i__];
00203
00204 }
00205 }
00206
00207
00208
00209 anorm = slangt_("1", n, &dl[1], &d__[1], &du[1]);
00210
00211
00212
00213
00214 *resid = slanhs_("1", n, &work[work_offset], ldwork, &rwork[1])
00215 ;
00216
00217
00218
00219 if (anorm <= 0.f) {
00220 if (*resid != 0.f) {
00221 *resid = 1.f / eps;
00222 }
00223 } else {
00224 *resid = *resid / anorm / eps;
00225 }
00226
00227 return 0;
00228
00229
00230
00231 }