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