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 integer c__1 = 1;
00019 static real c_b7 = -1.f;
00020 static real c_b9 = 1.f;
00021
00022 int sbdt01_(integer *m, integer *n, integer *kd, real *a,
00023 integer *lda, real *q, integer *ldq, real *d__, real *e, real *pt,
00024 integer *ldpt, real *work, real *resid)
00025 {
00026
00027 integer a_dim1, a_offset, pt_dim1, pt_offset, q_dim1, q_offset, i__1,
00028 i__2;
00029 real r__1, r__2;
00030
00031
00032 integer i__, j;
00033 real eps, anorm;
00034 extern int sgemv_(char *, integer *, integer *, real *,
00035 real *, integer *, real *, integer *, real *, real *, integer *);
00036 extern doublereal sasum_(integer *, real *, integer *);
00037 extern int scopy_(integer *, real *, integer *, real *,
00038 integer *);
00039 extern doublereal slamch_(char *), slange_(char *, integer *,
00040 integer *, real *, integer *, real *);
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
00128
00129
00130 a_dim1 = *lda;
00131 a_offset = 1 + a_dim1;
00132 a -= a_offset;
00133 q_dim1 = *ldq;
00134 q_offset = 1 + q_dim1;
00135 q -= q_offset;
00136 --d__;
00137 --e;
00138 pt_dim1 = *ldpt;
00139 pt_offset = 1 + pt_dim1;
00140 pt -= pt_offset;
00141 --work;
00142
00143
00144 if (*m <= 0 || *n <= 0) {
00145 *resid = 0.f;
00146 return 0;
00147 }
00148
00149
00150
00151 *resid = 0.f;
00152 if (*kd != 0) {
00153
00154
00155
00156 if (*kd != 0 && *m >= *n) {
00157
00158
00159
00160 i__1 = *n;
00161 for (j = 1; j <= i__1; ++j) {
00162 scopy_(m, &a[j * a_dim1 + 1], &c__1, &work[1], &c__1);
00163 i__2 = *n - 1;
00164 for (i__ = 1; i__ <= i__2; ++i__) {
00165 work[*m + i__] = d__[i__] * pt[i__ + j * pt_dim1] + e[i__]
00166 * pt[i__ + 1 + j * pt_dim1];
00167
00168 }
00169 work[*m + *n] = d__[*n] * pt[*n + j * pt_dim1];
00170 sgemv_("No transpose", m, n, &c_b7, &q[q_offset], ldq, &work[*
00171 m + 1], &c__1, &c_b9, &work[1], &c__1);
00172
00173 r__1 = *resid, r__2 = sasum_(m, &work[1], &c__1);
00174 *resid = dmax(r__1,r__2);
00175
00176 }
00177 } else if (*kd < 0) {
00178
00179
00180
00181 i__1 = *n;
00182 for (j = 1; j <= i__1; ++j) {
00183 scopy_(m, &a[j * a_dim1 + 1], &c__1, &work[1], &c__1);
00184 i__2 = *m - 1;
00185 for (i__ = 1; i__ <= i__2; ++i__) {
00186 work[*m + i__] = d__[i__] * pt[i__ + j * pt_dim1] + e[i__]
00187 * pt[i__ + 1 + j * pt_dim1];
00188
00189 }
00190 work[*m + *m] = d__[*m] * pt[*m + j * pt_dim1];
00191 sgemv_("No transpose", m, m, &c_b7, &q[q_offset], ldq, &work[*
00192 m + 1], &c__1, &c_b9, &work[1], &c__1);
00193
00194 r__1 = *resid, r__2 = sasum_(m, &work[1], &c__1);
00195 *resid = dmax(r__1,r__2);
00196
00197 }
00198 } else {
00199
00200
00201
00202 i__1 = *n;
00203 for (j = 1; j <= i__1; ++j) {
00204 scopy_(m, &a[j * a_dim1 + 1], &c__1, &work[1], &c__1);
00205 work[*m + 1] = d__[1] * pt[j * pt_dim1 + 1];
00206 i__2 = *m;
00207 for (i__ = 2; i__ <= i__2; ++i__) {
00208 work[*m + i__] = e[i__ - 1] * pt[i__ - 1 + j * pt_dim1] +
00209 d__[i__] * pt[i__ + j * pt_dim1];
00210
00211 }
00212 sgemv_("No transpose", m, m, &c_b7, &q[q_offset], ldq, &work[*
00213 m + 1], &c__1, &c_b9, &work[1], &c__1);
00214
00215 r__1 = *resid, r__2 = sasum_(m, &work[1], &c__1);
00216 *resid = dmax(r__1,r__2);
00217
00218 }
00219 }
00220 } else {
00221
00222
00223
00224 if (*m >= *n) {
00225 i__1 = *n;
00226 for (j = 1; j <= i__1; ++j) {
00227 scopy_(m, &a[j * a_dim1 + 1], &c__1, &work[1], &c__1);
00228 i__2 = *n;
00229 for (i__ = 1; i__ <= i__2; ++i__) {
00230 work[*m + i__] = d__[i__] * pt[i__ + j * pt_dim1];
00231
00232 }
00233 sgemv_("No transpose", m, n, &c_b7, &q[q_offset], ldq, &work[*
00234 m + 1], &c__1, &c_b9, &work[1], &c__1);
00235
00236 r__1 = *resid, r__2 = sasum_(m, &work[1], &c__1);
00237 *resid = dmax(r__1,r__2);
00238
00239 }
00240 } else {
00241 i__1 = *n;
00242 for (j = 1; j <= i__1; ++j) {
00243 scopy_(m, &a[j * a_dim1 + 1], &c__1, &work[1], &c__1);
00244 i__2 = *m;
00245 for (i__ = 1; i__ <= i__2; ++i__) {
00246 work[*m + i__] = d__[i__] * pt[i__ + j * pt_dim1];
00247
00248 }
00249 sgemv_("No transpose", m, m, &c_b7, &q[q_offset], ldq, &work[*
00250 m + 1], &c__1, &c_b9, &work[1], &c__1);
00251
00252 r__1 = *resid, r__2 = sasum_(m, &work[1], &c__1);
00253 *resid = dmax(r__1,r__2);
00254
00255 }
00256 }
00257 }
00258
00259
00260
00261 anorm = slange_("1", m, n, &a[a_offset], lda, &work[1]);
00262 eps = slamch_("Precision");
00263
00264 if (anorm <= 0.f) {
00265 if (*resid != 0.f) {
00266 *resid = 1.f / eps;
00267 }
00268 } else {
00269 if (anorm >= *resid) {
00270 *resid = *resid / anorm / ((real) (*n) * eps);
00271 } else {
00272 if (anorm < 1.f) {
00273
00274 r__1 = *resid, r__2 = (real) (*n) * anorm;
00275 *resid = dmin(r__1,r__2) / anorm / ((real) (*n) * eps);
00276 } else {
00277
00278 r__1 = *resid / anorm, r__2 = (real) (*n);
00279 *resid = dmin(r__1,r__2) / ((real) (*n) * eps);
00280 }
00281 }
00282 }
00283
00284 return 0;
00285
00286
00287
00288 }