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 real c_b6 = -1.f;
00019 static integer c__1 = 1;
00020 static real c_b8 = 0.f;
00021
00022 int sbdt03_(char *uplo, integer *n, integer *kd, real *d__,
00023 real *e, real *u, integer *ldu, real *s, real *vt, integer *ldvt,
00024 real *work, real *resid)
00025 {
00026
00027 integer u_dim1, u_offset, vt_dim1, vt_offset, i__1, i__2;
00028 real r__1, r__2, r__3, r__4;
00029
00030
00031 integer i__, j;
00032 real eps;
00033 extern logical lsame_(char *, char *);
00034 real bnorm;
00035 extern int sgemv_(char *, integer *, integer *, real *,
00036 real *, integer *, real *, integer *, real *, real *, integer *);
00037 extern doublereal sasum_(integer *, real *, integer *), slamch_(char *);
00038 extern integer isamax_(integer *, real *, integer *);
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
00118
00119
00120
00121
00122
00123
00124
00125 --d__;
00126 --e;
00127 u_dim1 = *ldu;
00128 u_offset = 1 + u_dim1;
00129 u -= u_offset;
00130 --s;
00131 vt_dim1 = *ldvt;
00132 vt_offset = 1 + vt_dim1;
00133 vt -= vt_offset;
00134 --work;
00135
00136
00137 *resid = 0.f;
00138 if (*n <= 0) {
00139 return 0;
00140 }
00141
00142
00143
00144 bnorm = 0.f;
00145 if (*kd >= 1) {
00146
00147
00148
00149 if (lsame_(uplo, "U")) {
00150
00151
00152
00153 i__1 = *n;
00154 for (j = 1; j <= i__1; ++j) {
00155 i__2 = *n;
00156 for (i__ = 1; i__ <= i__2; ++i__) {
00157 work[*n + i__] = s[i__] * vt[i__ + j * vt_dim1];
00158
00159 }
00160 sgemv_("No transpose", n, n, &c_b6, &u[u_offset], ldu, &work[*
00161 n + 1], &c__1, &c_b8, &work[1], &c__1);
00162 work[j] += d__[j];
00163 if (j > 1) {
00164 work[j - 1] += e[j - 1];
00165
00166 r__3 = bnorm, r__4 = (r__1 = d__[j], dabs(r__1)) + (r__2 =
00167 e[j - 1], dabs(r__2));
00168 bnorm = dmax(r__3,r__4);
00169 } else {
00170
00171 r__2 = bnorm, r__3 = (r__1 = d__[j], dabs(r__1));
00172 bnorm = dmax(r__2,r__3);
00173 }
00174
00175 r__1 = *resid, r__2 = sasum_(n, &work[1], &c__1);
00176 *resid = dmax(r__1,r__2);
00177
00178 }
00179 } else {
00180
00181
00182
00183 i__1 = *n;
00184 for (j = 1; j <= i__1; ++j) {
00185 i__2 = *n;
00186 for (i__ = 1; i__ <= i__2; ++i__) {
00187 work[*n + i__] = s[i__] * vt[i__ + j * vt_dim1];
00188
00189 }
00190 sgemv_("No transpose", n, n, &c_b6, &u[u_offset], ldu, &work[*
00191 n + 1], &c__1, &c_b8, &work[1], &c__1);
00192 work[j] += d__[j];
00193 if (j < *n) {
00194 work[j + 1] += e[j];
00195
00196 r__3 = bnorm, r__4 = (r__1 = d__[j], dabs(r__1)) + (r__2 =
00197 e[j], dabs(r__2));
00198 bnorm = dmax(r__3,r__4);
00199 } else {
00200
00201 r__2 = bnorm, r__3 = (r__1 = d__[j], dabs(r__1));
00202 bnorm = dmax(r__2,r__3);
00203 }
00204
00205 r__1 = *resid, r__2 = sasum_(n, &work[1], &c__1);
00206 *resid = dmax(r__1,r__2);
00207
00208 }
00209 }
00210 } else {
00211
00212
00213
00214 i__1 = *n;
00215 for (j = 1; j <= i__1; ++j) {
00216 i__2 = *n;
00217 for (i__ = 1; i__ <= i__2; ++i__) {
00218 work[*n + i__] = s[i__] * vt[i__ + j * vt_dim1];
00219
00220 }
00221 sgemv_("No transpose", n, n, &c_b6, &u[u_offset], ldu, &work[*n +
00222 1], &c__1, &c_b8, &work[1], &c__1);
00223 work[j] += d__[j];
00224
00225 r__1 = *resid, r__2 = sasum_(n, &work[1], &c__1);
00226 *resid = dmax(r__1,r__2);
00227
00228 }
00229 j = isamax_(n, &d__[1], &c__1);
00230 bnorm = (r__1 = d__[j], dabs(r__1));
00231 }
00232
00233
00234
00235 eps = slamch_("Precision");
00236
00237 if (bnorm <= 0.f) {
00238 if (*resid != 0.f) {
00239 *resid = 1.f / eps;
00240 }
00241 } else {
00242 if (bnorm >= *resid) {
00243 *resid = *resid / bnorm / ((real) (*n) * eps);
00244 } else {
00245 if (bnorm < 1.f) {
00246
00247 r__1 = *resid, r__2 = (real) (*n) * bnorm;
00248 *resid = dmin(r__1,r__2) / bnorm / ((real) (*n) * eps);
00249 } else {
00250
00251 r__1 = *resid / bnorm, r__2 = (real) (*n);
00252 *resid = dmin(r__1,r__2) / ((real) (*n) * eps);
00253 }
00254 }
00255 }
00256
00257 return 0;
00258
00259
00260
00261 }