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
00021 int cstt22_(integer *n, integer *m, integer *kband, real *ad,
00022 real *ae, real *sd, real *se, complex *u, integer *ldu, complex *
00023 work, integer *ldwork, real *rwork, real *result)
00024 {
00025
00026 integer u_dim1, u_offset, work_dim1, work_offset, i__1, i__2, i__3, i__4,
00027 i__5, i__6;
00028 real r__1, r__2, r__3, r__4, r__5;
00029 complex q__1, q__2;
00030
00031
00032 integer i__, j, k;
00033 real ulp;
00034 complex aukj;
00035 real unfl;
00036 extern int cgemm_(char *, char *, integer *, integer *,
00037 integer *, complex *, complex *, integer *, complex *, integer *,
00038 complex *, complex *, integer *);
00039 real anorm, wnorm;
00040 extern doublereal clange_(char *, integer *, integer *, complex *,
00041 integer *, real *), slamch_(char *), clansy_(char
00042 *, char *, integer *, complex *, integer *, real *);
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
00131
00132
00133
00134
00135 --ad;
00136 --ae;
00137 --sd;
00138 --se;
00139 u_dim1 = *ldu;
00140 u_offset = 1 + u_dim1;
00141 u -= u_offset;
00142 work_dim1 = *ldwork;
00143 work_offset = 1 + work_dim1;
00144 work -= work_offset;
00145 --rwork;
00146 --result;
00147
00148
00149 result[1] = 0.f;
00150 result[2] = 0.f;
00151 if (*n <= 0 || *m <= 0) {
00152 return 0;
00153 }
00154
00155 unfl = slamch_("Safe minimum");
00156 ulp = slamch_("Epsilon");
00157
00158
00159
00160
00161
00162 if (*n > 1) {
00163 anorm = dabs(ad[1]) + dabs(ae[1]);
00164 i__1 = *n - 1;
00165 for (j = 2; j <= i__1; ++j) {
00166
00167 r__4 = anorm, r__5 = (r__1 = ad[j], dabs(r__1)) + (r__2 = ae[j],
00168 dabs(r__2)) + (r__3 = ae[j - 1], dabs(r__3));
00169 anorm = dmax(r__4,r__5);
00170
00171 }
00172
00173 r__3 = anorm, r__4 = (r__1 = ad[*n], dabs(r__1)) + (r__2 = ae[*n - 1],
00174 dabs(r__2));
00175 anorm = dmax(r__3,r__4);
00176 } else {
00177 anorm = dabs(ad[1]);
00178 }
00179 anorm = dmax(anorm,unfl);
00180
00181
00182
00183 i__1 = *m;
00184 for (i__ = 1; i__ <= i__1; ++i__) {
00185 i__2 = *m;
00186 for (j = 1; j <= i__2; ++j) {
00187 i__3 = i__ + j * work_dim1;
00188 work[i__3].r = 0.f, work[i__3].i = 0.f;
00189 i__3 = *n;
00190 for (k = 1; k <= i__3; ++k) {
00191 i__4 = k;
00192 i__5 = k + j * u_dim1;
00193 q__1.r = ad[i__4] * u[i__5].r, q__1.i = ad[i__4] * u[i__5].i;
00194 aukj.r = q__1.r, aukj.i = q__1.i;
00195 if (k != *n) {
00196 i__4 = k;
00197 i__5 = k + 1 + j * u_dim1;
00198 q__2.r = ae[i__4] * u[i__5].r, q__2.i = ae[i__4] * u[i__5]
00199 .i;
00200 q__1.r = aukj.r + q__2.r, q__1.i = aukj.i + q__2.i;
00201 aukj.r = q__1.r, aukj.i = q__1.i;
00202 }
00203 if (k != 1) {
00204 i__4 = k - 1;
00205 i__5 = k - 1 + j * u_dim1;
00206 q__2.r = ae[i__4] * u[i__5].r, q__2.i = ae[i__4] * u[i__5]
00207 .i;
00208 q__1.r = aukj.r + q__2.r, q__1.i = aukj.i + q__2.i;
00209 aukj.r = q__1.r, aukj.i = q__1.i;
00210 }
00211 i__4 = i__ + j * work_dim1;
00212 i__5 = i__ + j * work_dim1;
00213 i__6 = k + i__ * u_dim1;
00214 q__2.r = u[i__6].r * aukj.r - u[i__6].i * aukj.i, q__2.i = u[
00215 i__6].r * aukj.i + u[i__6].i * aukj.r;
00216 q__1.r = work[i__5].r + q__2.r, q__1.i = work[i__5].i +
00217 q__2.i;
00218 work[i__4].r = q__1.r, work[i__4].i = q__1.i;
00219
00220 }
00221
00222 }
00223 i__2 = i__ + i__ * work_dim1;
00224 i__3 = i__ + i__ * work_dim1;
00225 i__4 = i__;
00226 q__1.r = work[i__3].r - sd[i__4], q__1.i = work[i__3].i;
00227 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00228 if (*kband == 1) {
00229 if (i__ != 1) {
00230 i__2 = i__ + (i__ - 1) * work_dim1;
00231 i__3 = i__ + (i__ - 1) * work_dim1;
00232 i__4 = i__ - 1;
00233 q__1.r = work[i__3].r - se[i__4], q__1.i = work[i__3].i;
00234 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00235 }
00236 if (i__ != *n) {
00237 i__2 = i__ + (i__ + 1) * work_dim1;
00238 i__3 = i__ + (i__ + 1) * work_dim1;
00239 i__4 = i__;
00240 q__1.r = work[i__3].r - se[i__4], q__1.i = work[i__3].i;
00241 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00242 }
00243 }
00244
00245 }
00246
00247 wnorm = clansy_("1", "L", m, &work[work_offset], m, &rwork[1]);
00248
00249 if (anorm > wnorm) {
00250 result[1] = wnorm / anorm / (*m * ulp);
00251 } else {
00252 if (anorm < 1.f) {
00253
00254 r__1 = wnorm, r__2 = *m * anorm;
00255 result[1] = dmin(r__1,r__2) / anorm / (*m * ulp);
00256 } else {
00257
00258 r__1 = wnorm / anorm, r__2 = (real) (*m);
00259 result[1] = dmin(r__1,r__2) / (*m * ulp);
00260 }
00261 }
00262
00263
00264
00265
00266
00267 cgemm_("T", "N", m, m, n, &c_b2, &u[u_offset], ldu, &u[u_offset], ldu, &
00268 c_b1, &work[work_offset], m);
00269
00270 i__1 = *m;
00271 for (j = 1; j <= i__1; ++j) {
00272 i__2 = j + j * work_dim1;
00273 i__3 = j + j * work_dim1;
00274 q__1.r = work[i__3].r - 1.f, q__1.i = work[i__3].i;
00275 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00276
00277 }
00278
00279
00280 r__1 = (real) (*m), r__2 = clange_("1", m, m, &work[work_offset], m, &
00281 rwork[1]);
00282 result[2] = dmin(r__1,r__2) / (*m * ulp);
00283
00284 return 0;
00285
00286
00287
00288 }