00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016
00017
00018 static complex c_b6 = {-1.f,-0.f};
00019 static integer c__1 = 1;
00020 static complex c_b9 = {0.f,0.f};
00021
00022 int cbdt03_(char *uplo, integer *n, integer *kd, real *d__,
00023 real *e, complex *u, integer *ldu, real *s, complex *vt, integer *
00024 ldvt, complex *work, real *resid)
00025 {
00026
00027 integer u_dim1, u_offset, vt_dim1, vt_offset, i__1, i__2, i__3, i__4,
00028 i__5;
00029 real r__1, r__2, r__3, r__4;
00030 complex q__1;
00031
00032
00033 integer i__, j;
00034 real eps;
00035 extern logical lsame_(char *, char *);
00036 extern int cgemv_(char *, integer *, integer *, complex *
00037 , complex *, integer *, complex *, integer *, complex *, complex *
00038 , integer *);
00039 real bnorm;
00040 extern doublereal slamch_(char *);
00041 extern integer isamax_(integer *, real *, integer *);
00042 extern doublereal scasum_(integer *, complex *, integer *);
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
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 --d__;
00130 --e;
00131 u_dim1 = *ldu;
00132 u_offset = 1 + u_dim1;
00133 u -= u_offset;
00134 --s;
00135 vt_dim1 = *ldvt;
00136 vt_offset = 1 + vt_dim1;
00137 vt -= vt_offset;
00138 --work;
00139
00140
00141 *resid = 0.f;
00142 if (*n <= 0) {
00143 return 0;
00144 }
00145
00146
00147
00148 bnorm = 0.f;
00149 if (*kd >= 1) {
00150
00151
00152
00153 if (lsame_(uplo, "U")) {
00154
00155
00156
00157 i__1 = *n;
00158 for (j = 1; j <= i__1; ++j) {
00159 i__2 = *n;
00160 for (i__ = 1; i__ <= i__2; ++i__) {
00161 i__3 = *n + i__;
00162 i__4 = i__;
00163 i__5 = i__ + j * vt_dim1;
00164 q__1.r = s[i__4] * vt[i__5].r, q__1.i = s[i__4] * vt[i__5]
00165 .i;
00166 work[i__3].r = q__1.r, work[i__3].i = q__1.i;
00167
00168 }
00169 cgemv_("No transpose", n, n, &c_b6, &u[u_offset], ldu, &work[*
00170 n + 1], &c__1, &c_b9, &work[1], &c__1);
00171 i__2 = j;
00172 i__3 = j;
00173 i__4 = j;
00174 q__1.r = work[i__3].r + d__[i__4], q__1.i = work[i__3].i;
00175 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00176 if (j > 1) {
00177 i__2 = j - 1;
00178 i__3 = j - 1;
00179 i__4 = j - 1;
00180 q__1.r = work[i__3].r + e[i__4], q__1.i = work[i__3].i;
00181 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00182
00183 r__3 = bnorm, r__4 = (r__1 = d__[j], dabs(r__1)) + (r__2 =
00184 e[j - 1], dabs(r__2));
00185 bnorm = dmax(r__3,r__4);
00186 } else {
00187
00188 r__2 = bnorm, r__3 = (r__1 = d__[j], dabs(r__1));
00189 bnorm = dmax(r__2,r__3);
00190 }
00191
00192 r__1 = *resid, r__2 = scasum_(n, &work[1], &c__1);
00193 *resid = dmax(r__1,r__2);
00194
00195 }
00196 } else {
00197
00198
00199
00200 i__1 = *n;
00201 for (j = 1; j <= i__1; ++j) {
00202 i__2 = *n;
00203 for (i__ = 1; i__ <= i__2; ++i__) {
00204 i__3 = *n + i__;
00205 i__4 = i__;
00206 i__5 = i__ + j * vt_dim1;
00207 q__1.r = s[i__4] * vt[i__5].r, q__1.i = s[i__4] * vt[i__5]
00208 .i;
00209 work[i__3].r = q__1.r, work[i__3].i = q__1.i;
00210
00211 }
00212 cgemv_("No transpose", n, n, &c_b6, &u[u_offset], ldu, &work[*
00213 n + 1], &c__1, &c_b9, &work[1], &c__1);
00214 i__2 = j;
00215 i__3 = j;
00216 i__4 = j;
00217 q__1.r = work[i__3].r + d__[i__4], q__1.i = work[i__3].i;
00218 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00219 if (j < *n) {
00220 i__2 = j + 1;
00221 i__3 = j + 1;
00222 i__4 = j;
00223 q__1.r = work[i__3].r + e[i__4], q__1.i = work[i__3].i;
00224 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00225
00226 r__3 = bnorm, r__4 = (r__1 = d__[j], dabs(r__1)) + (r__2 =
00227 e[j], dabs(r__2));
00228 bnorm = dmax(r__3,r__4);
00229 } else {
00230
00231 r__2 = bnorm, r__3 = (r__1 = d__[j], dabs(r__1));
00232 bnorm = dmax(r__2,r__3);
00233 }
00234
00235 r__1 = *resid, r__2 = scasum_(n, &work[1], &c__1);
00236 *resid = dmax(r__1,r__2);
00237
00238 }
00239 }
00240 } else {
00241
00242
00243
00244 i__1 = *n;
00245 for (j = 1; j <= i__1; ++j) {
00246 i__2 = *n;
00247 for (i__ = 1; i__ <= i__2; ++i__) {
00248 i__3 = *n + i__;
00249 i__4 = i__;
00250 i__5 = i__ + j * vt_dim1;
00251 q__1.r = s[i__4] * vt[i__5].r, q__1.i = s[i__4] * vt[i__5].i;
00252 work[i__3].r = q__1.r, work[i__3].i = q__1.i;
00253
00254 }
00255 cgemv_("No transpose", n, n, &c_b6, &u[u_offset], ldu, &work[*n +
00256 1], &c__1, &c_b9, &work[1], &c__1);
00257 i__2 = j;
00258 i__3 = j;
00259 i__4 = j;
00260 q__1.r = work[i__3].r + d__[i__4], q__1.i = work[i__3].i;
00261 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00262
00263 r__1 = *resid, r__2 = scasum_(n, &work[1], &c__1);
00264 *resid = dmax(r__1,r__2);
00265
00266 }
00267 j = isamax_(n, &d__[1], &c__1);
00268 bnorm = (r__1 = d__[j], dabs(r__1));
00269 }
00270
00271
00272
00273 eps = slamch_("Precision");
00274
00275 if (bnorm <= 0.f) {
00276 if (*resid != 0.f) {
00277 *resid = 1.f / eps;
00278 }
00279 } else {
00280 if (bnorm >= *resid) {
00281 *resid = *resid / bnorm / ((real) (*n) * eps);
00282 } else {
00283 if (bnorm < 1.f) {
00284
00285 r__1 = *resid, r__2 = (real) (*n) * bnorm;
00286 *resid = dmin(r__1,r__2) / bnorm / ((real) (*n) * eps);
00287 } else {
00288
00289 r__1 = *resid / bnorm, r__2 = (real) (*n);
00290 *resid = dmin(r__1,r__2) / ((real) (*n) * eps);
00291 }
00292 }
00293 }
00294
00295 return 0;
00296
00297
00298
00299 }