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