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 complex c_b1 = {0.f,0.f};
00019 static complex c_b2 = {1.f,0.f};
00020 static integer c__1 = 1;
00021
00022 int cstt21_(integer *n, integer *kband, real *ad, real *ae,
00023 real *sd, real *se, complex *u, integer *ldu, complex *work, real *
00024 rwork, real *result)
00025 {
00026
00027 integer u_dim1, u_offset, i__1, i__2, i__3;
00028 real r__1, r__2, r__3;
00029 complex q__1, q__2;
00030
00031
00032 integer j;
00033 real ulp;
00034 extern int cher_(char *, integer *, real *, complex *,
00035 integer *, complex *, integer *);
00036 real unfl;
00037 extern int cher2_(char *, integer *, complex *, complex *
00038 , integer *, complex *, integer *, complex *, integer *);
00039 real temp1, temp2;
00040 extern int cgemm_(char *, char *, integer *, integer *,
00041 integer *, complex *, complex *, integer *, complex *, integer *,
00042 complex *, complex *, integer *);
00043 real anorm, wnorm;
00044 extern doublereal clange_(char *, integer *, integer *, complex *,
00045 integer *, real *), clanhe_(char *, char *, integer *,
00046 complex *, integer *, real *), slamch_(char *);
00047 extern int claset_(char *, integer *, integer *, complex
00048 *, complex *, complex *, integer *);
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 --ad;
00138 --ae;
00139 --sd;
00140 --se;
00141 u_dim1 = *ldu;
00142 u_offset = 1 + u_dim1;
00143 u -= u_offset;
00144 --work;
00145 --rwork;
00146 --result;
00147
00148
00149 result[1] = 0.f;
00150 result[2] = 0.f;
00151 if (*n <= 0) {
00152 return 0;
00153 }
00154
00155 unfl = slamch_("Safe minimum");
00156 ulp = slamch_("Precision");
00157
00158
00159
00160
00161
00162 claset_("Full", n, n, &c_b1, &c_b1, &work[1], n);
00163
00164 anorm = 0.f;
00165 temp1 = 0.f;
00166
00167 i__1 = *n - 1;
00168 for (j = 1; j <= i__1; ++j) {
00169 i__2 = (*n + 1) * (j - 1) + 1;
00170 i__3 = j;
00171 work[i__2].r = ad[i__3], work[i__2].i = 0.f;
00172 i__2 = (*n + 1) * (j - 1) + 2;
00173 i__3 = j;
00174 work[i__2].r = ae[i__3], work[i__2].i = 0.f;
00175 temp2 = (r__1 = ae[j], dabs(r__1));
00176
00177 r__2 = anorm, r__3 = (r__1 = ad[j], dabs(r__1)) + temp1 + temp2;
00178 anorm = dmax(r__2,r__3);
00179 temp1 = temp2;
00180
00181 }
00182
00183
00184 i__2 = *n;
00185 i__1 = i__2 * i__2;
00186 i__3 = *n;
00187 work[i__1].r = ad[i__3], work[i__1].i = 0.f;
00188
00189 r__2 = anorm, r__3 = (r__1 = ad[*n], dabs(r__1)) + temp1, r__2 = max(r__2,
00190 r__3);
00191 anorm = dmax(r__2,unfl);
00192
00193
00194
00195 i__1 = *n;
00196 for (j = 1; j <= i__1; ++j) {
00197 r__1 = -sd[j];
00198 cher_("L", n, &r__1, &u[j * u_dim1 + 1], &c__1, &work[1], n);
00199
00200 }
00201
00202 if (*n > 1 && *kband == 1) {
00203 i__1 = *n - 1;
00204 for (j = 1; j <= i__1; ++j) {
00205 i__2 = j;
00206 q__2.r = se[i__2], q__2.i = 0.f;
00207 q__1.r = -q__2.r, q__1.i = -q__2.i;
00208 cher2_("L", n, &q__1, &u[j * u_dim1 + 1], &c__1, &u[(j + 1) *
00209 u_dim1 + 1], &c__1, &work[1], n);
00210
00211 }
00212 }
00213
00214 wnorm = clanhe_("1", "L", n, &work[1], n, &rwork[1])
00215 ;
00216
00217 if (anorm > wnorm) {
00218 result[1] = wnorm / anorm / (*n * ulp);
00219 } else {
00220 if (anorm < 1.f) {
00221
00222 r__1 = wnorm, r__2 = *n * anorm;
00223 result[1] = dmin(r__1,r__2) / anorm / (*n * ulp);
00224 } else {
00225
00226 r__1 = wnorm / anorm, r__2 = (real) (*n);
00227 result[1] = dmin(r__1,r__2) / (*n * ulp);
00228 }
00229 }
00230
00231
00232
00233
00234
00235 cgemm_("N", "C", n, n, n, &c_b2, &u[u_offset], ldu, &u[u_offset], ldu, &
00236 c_b1, &work[1], n);
00237
00238 i__1 = *n;
00239 for (j = 1; j <= i__1; ++j) {
00240 i__2 = (*n + 1) * (j - 1) + 1;
00241 i__3 = (*n + 1) * (j - 1) + 1;
00242 q__1.r = work[i__3].r - 1.f, q__1.i = work[i__3].i - 0.f;
00243 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00244
00245 }
00246
00247
00248 r__1 = (real) (*n), r__2 = clange_("1", n, n, &work[1], n, &rwork[1]);
00249 result[2] = dmin(r__1,r__2) / (*n * ulp);
00250
00251 return 0;
00252
00253
00254
00255 }