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_b22 = 1.;
00020 static doublereal c_b23 = 0.;
00021
00022 int dsbt21_(char *uplo, integer *n, integer *ka, integer *ks,
00023 doublereal *a, integer *lda, doublereal *d__, doublereal *e,
00024 doublereal *u, integer *ldu, doublereal *work, doublereal *result)
00025 {
00026
00027 integer a_dim1, a_offset, u_dim1, u_offset, i__1, i__2, i__3, i__4;
00028 doublereal d__1, d__2;
00029
00030
00031 integer j, jc, jr, lw, ika;
00032 doublereal ulp, unfl;
00033 extern int dspr_(char *, integer *, doublereal *,
00034 doublereal *, integer *, doublereal *), dspr2_(char *,
00035 integer *, doublereal *, doublereal *, integer *, doublereal *,
00036 integer *, doublereal *), dgemm_(char *, char *, integer *
00037 , integer *, integer *, doublereal *, doublereal *, integer *,
00038 doublereal *, integer *, doublereal *, doublereal *, integer *);
00039 extern logical lsame_(char *, char *);
00040 doublereal anorm;
00041 char cuplo[1];
00042 logical lower;
00043 doublereal wnorm;
00044 extern doublereal dlamch_(char *), dlange_(char *, integer *,
00045 integer *, doublereal *, integer *, doublereal *),
00046 dlansb_(char *, char *, integer *, integer *, doublereal *,
00047 integer *, doublereal *), dlansp_(char *, char *,
00048 integer *, doublereal *, doublereal *);
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
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 a_dim1 = *lda;
00149 a_offset = 1 + a_dim1;
00150 a -= a_offset;
00151 --d__;
00152 --e;
00153 u_dim1 = *ldu;
00154 u_offset = 1 + u_dim1;
00155 u -= u_offset;
00156 --work;
00157 --result;
00158
00159
00160 result[1] = 0.;
00161 result[2] = 0.;
00162 if (*n <= 0) {
00163 return 0;
00164 }
00165
00166
00167
00168 i__3 = *n - 1;
00169 i__1 = 0, i__2 = min(i__3,*ka);
00170 ika = max(i__1,i__2);
00171 lw = *n * (*n + 1) / 2;
00172
00173 if (lsame_(uplo, "U")) {
00174 lower = FALSE_;
00175 *(unsigned char *)cuplo = 'U';
00176 } else {
00177 lower = TRUE_;
00178 *(unsigned char *)cuplo = 'L';
00179 }
00180
00181 unfl = dlamch_("Safe minimum");
00182 ulp = dlamch_("Epsilon") * dlamch_("Base");
00183
00184
00185
00186
00187
00188
00189
00190
00191 d__1 = dlansb_("1", cuplo, n, &ika, &a[a_offset], lda, &work[1]);
00192 anorm = max(d__1,unfl);
00193
00194
00195
00196
00197
00198 j = 0;
00199 i__1 = *n;
00200 for (jc = 1; jc <= i__1; ++jc) {
00201 if (lower) {
00202
00203 i__3 = ika + 1, i__4 = *n + 1 - jc;
00204 i__2 = min(i__3,i__4);
00205 for (jr = 1; jr <= i__2; ++jr) {
00206 ++j;
00207 work[j] = a[jr + jc * a_dim1];
00208
00209 }
00210 i__2 = *n + 1 - jc;
00211 for (jr = ika + 2; jr <= i__2; ++jr) {
00212 ++j;
00213 work[j] = 0.;
00214
00215 }
00216 } else {
00217 i__2 = jc;
00218 for (jr = ika + 2; jr <= i__2; ++jr) {
00219 ++j;
00220 work[j] = 0.;
00221
00222 }
00223
00224 i__2 = ika, i__3 = jc - 1;
00225 for (jr = min(i__2,i__3); jr >= 0; --jr) {
00226 ++j;
00227 work[j] = a[ika + 1 - jr + jc * a_dim1];
00228
00229 }
00230 }
00231
00232 }
00233
00234 i__1 = *n;
00235 for (j = 1; j <= i__1; ++j) {
00236 d__1 = -d__[j];
00237 dspr_(cuplo, n, &d__1, &u[j * u_dim1 + 1], &c__1, &work[1])
00238 ;
00239
00240 }
00241
00242 if (*n > 1 && *ks == 1) {
00243 i__1 = *n - 1;
00244 for (j = 1; j <= i__1; ++j) {
00245 d__1 = -e[j];
00246 dspr2_(cuplo, n, &d__1, &u[j * u_dim1 + 1], &c__1, &u[(j + 1) *
00247 u_dim1 + 1], &c__1, &work[1]);
00248
00249 }
00250 }
00251 wnorm = dlansp_("1", cuplo, n, &work[1], &work[lw + 1]);
00252
00253 if (anorm > wnorm) {
00254 result[1] = wnorm / anorm / (*n * ulp);
00255 } else {
00256 if (anorm < 1.) {
00257
00258 d__1 = wnorm, d__2 = *n * anorm;
00259 result[1] = min(d__1,d__2) / anorm / (*n * ulp);
00260 } else {
00261
00262 d__1 = wnorm / anorm, d__2 = (doublereal) (*n);
00263 result[1] = min(d__1,d__2) / (*n * ulp);
00264 }
00265 }
00266
00267
00268
00269
00270
00271 dgemm_("N", "C", n, n, n, &c_b22, &u[u_offset], ldu, &u[u_offset], ldu, &
00272 c_b23, &work[1], n);
00273
00274 i__1 = *n;
00275 for (j = 1; j <= i__1; ++j) {
00276 work[(*n + 1) * (j - 1) + 1] += -1.;
00277
00278 }
00279
00280
00281
00282 i__1 = *n;
00283 d__1 = dlange_("1", n, n, &work[1], n, &work[i__1 * i__1 + 1]),
00284 d__2 = (doublereal) (*n);
00285 result[2] = min(d__1,d__2) / (*n * ulp);
00286
00287 return 0;
00288
00289
00290
00291 }