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 cget22_(char *transa, char *transe, char *transw,
00022 integer *n, complex *a, integer *lda, complex *e, integer *lde,
00023 complex *w, complex *work, real *rwork, real *result)
00024 {
00025
00026 integer a_dim1, a_offset, e_dim1, e_offset, i__1, i__2, i__3, i__4;
00027 real r__1, r__2, r__3, r__4;
00028 complex q__1, q__2;
00029
00030
00031 double r_imag(complex *);
00032 void r_cnjg(complex *, complex *);
00033
00034
00035 integer j;
00036 real ulp;
00037 integer joff, jcol, jvec;
00038 real unfl;
00039 integer jrow;
00040 real temp1;
00041 extern int cgemm_(char *, char *, integer *, integer *,
00042 integer *, complex *, complex *, integer *, complex *, integer *,
00043 complex *, complex *, integer *);
00044 extern logical lsame_(char *, char *);
00045 char norma[1];
00046 real anorm;
00047 char norme[1];
00048 real enorm;
00049 complex wtemp;
00050 extern doublereal clange_(char *, integer *, integer *, complex *,
00051 integer *, real *), slamch_(char *);
00052 extern int claset_(char *, integer *, integer *, complex
00053 *, complex *, complex *, integer *);
00054 real enrmin, enrmax;
00055 integer itrnse;
00056 real errnrm;
00057 integer itrnsw;
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
00149
00150
00151
00152
00153 a_dim1 = *lda;
00154 a_offset = 1 + a_dim1;
00155 a -= a_offset;
00156 e_dim1 = *lde;
00157 e_offset = 1 + e_dim1;
00158 e -= e_offset;
00159 --w;
00160 --work;
00161 --rwork;
00162 --result;
00163
00164
00165 result[1] = 0.f;
00166 result[2] = 0.f;
00167 if (*n <= 0) {
00168 return 0;
00169 }
00170
00171 unfl = slamch_("Safe minimum");
00172 ulp = slamch_("Precision");
00173
00174 itrnse = 0;
00175 itrnsw = 0;
00176 *(unsigned char *)norma = 'O';
00177 *(unsigned char *)norme = 'O';
00178
00179 if (lsame_(transa, "T") || lsame_(transa, "C")) {
00180 *(unsigned char *)norma = 'I';
00181 }
00182
00183 if (lsame_(transe, "T")) {
00184 itrnse = 1;
00185 *(unsigned char *)norme = 'I';
00186 } else if (lsame_(transe, "C")) {
00187 itrnse = 2;
00188 *(unsigned char *)norme = 'I';
00189 }
00190
00191 if (lsame_(transw, "C")) {
00192 itrnsw = 1;
00193 }
00194
00195
00196
00197 enrmin = 1.f / ulp;
00198 enrmax = 0.f;
00199 if (itrnse == 0) {
00200 i__1 = *n;
00201 for (jvec = 1; jvec <= i__1; ++jvec) {
00202 temp1 = 0.f;
00203 i__2 = *n;
00204 for (j = 1; j <= i__2; ++j) {
00205
00206 i__3 = j + jvec * e_dim1;
00207 r__3 = temp1, r__4 = (r__1 = e[i__3].r, dabs(r__1)) + (r__2 =
00208 r_imag(&e[j + jvec * e_dim1]), dabs(r__2));
00209 temp1 = dmax(r__3,r__4);
00210
00211 }
00212 enrmin = dmin(enrmin,temp1);
00213 enrmax = dmax(enrmax,temp1);
00214
00215 }
00216 } else {
00217 i__1 = *n;
00218 for (jvec = 1; jvec <= i__1; ++jvec) {
00219 rwork[jvec] = 0.f;
00220
00221 }
00222
00223 i__1 = *n;
00224 for (j = 1; j <= i__1; ++j) {
00225 i__2 = *n;
00226 for (jvec = 1; jvec <= i__2; ++jvec) {
00227
00228 i__3 = jvec + j * e_dim1;
00229 r__3 = rwork[jvec], r__4 = (r__1 = e[i__3].r, dabs(r__1)) + (
00230 r__2 = r_imag(&e[jvec + j * e_dim1]), dabs(r__2));
00231 rwork[jvec] = dmax(r__3,r__4);
00232
00233 }
00234
00235 }
00236
00237 i__1 = *n;
00238 for (jvec = 1; jvec <= i__1; ++jvec) {
00239
00240 r__1 = enrmin, r__2 = rwork[jvec];
00241 enrmin = dmin(r__1,r__2);
00242
00243 r__1 = enrmax, r__2 = rwork[jvec];
00244 enrmax = dmax(r__1,r__2);
00245
00246 }
00247 }
00248
00249
00250
00251
00252 r__1 = clange_(norma, n, n, &a[a_offset], lda, &rwork[1]);
00253 anorm = dmax(r__1,unfl);
00254
00255
00256
00257
00258 r__1 = clange_(norme, n, n, &e[e_offset], lde, &rwork[1]);
00259 enorm = dmax(r__1,ulp);
00260
00261
00262
00263
00264
00265 claset_("Full", n, n, &c_b1, &c_b1, &work[1], n);
00266
00267 joff = 0;
00268 i__1 = *n;
00269 for (jcol = 1; jcol <= i__1; ++jcol) {
00270 if (itrnsw == 0) {
00271 i__2 = jcol;
00272 wtemp.r = w[i__2].r, wtemp.i = w[i__2].i;
00273 } else {
00274 r_cnjg(&q__1, &w[jcol]);
00275 wtemp.r = q__1.r, wtemp.i = q__1.i;
00276 }
00277
00278 if (itrnse == 0) {
00279 i__2 = *n;
00280 for (jrow = 1; jrow <= i__2; ++jrow) {
00281 i__3 = joff + jrow;
00282 i__4 = jrow + jcol * e_dim1;
00283 q__1.r = e[i__4].r * wtemp.r - e[i__4].i * wtemp.i, q__1.i =
00284 e[i__4].r * wtemp.i + e[i__4].i * wtemp.r;
00285 work[i__3].r = q__1.r, work[i__3].i = q__1.i;
00286
00287 }
00288 } else if (itrnse == 1) {
00289 i__2 = *n;
00290 for (jrow = 1; jrow <= i__2; ++jrow) {
00291 i__3 = joff + jrow;
00292 i__4 = jcol + jrow * e_dim1;
00293 q__1.r = e[i__4].r * wtemp.r - e[i__4].i * wtemp.i, q__1.i =
00294 e[i__4].r * wtemp.i + e[i__4].i * wtemp.r;
00295 work[i__3].r = q__1.r, work[i__3].i = q__1.i;
00296
00297 }
00298 } else {
00299 i__2 = *n;
00300 for (jrow = 1; jrow <= i__2; ++jrow) {
00301 i__3 = joff + jrow;
00302 r_cnjg(&q__2, &e[jcol + jrow * e_dim1]);
00303 q__1.r = q__2.r * wtemp.r - q__2.i * wtemp.i, q__1.i = q__2.r
00304 * wtemp.i + q__2.i * wtemp.r;
00305 work[i__3].r = q__1.r, work[i__3].i = q__1.i;
00306
00307 }
00308 }
00309 joff += *n;
00310
00311 }
00312
00313 q__1.r = -1.f, q__1.i = -0.f;
00314 cgemm_(transa, transe, n, n, n, &c_b2, &a[a_offset], lda, &e[e_offset],
00315 lde, &q__1, &work[1], n);
00316
00317 errnrm = clange_("One", n, n, &work[1], n, &rwork[1]) / enorm;
00318
00319
00320
00321 if (anorm > errnrm) {
00322 result[1] = errnrm / anorm / ulp;
00323 } else {
00324 if (anorm < 1.f) {
00325 result[1] = dmin(errnrm,anorm) / anorm / ulp;
00326 } else {
00327
00328 r__1 = errnrm / anorm;
00329 result[1] = dmin(r__1,1.f) / ulp;
00330 }
00331 }
00332
00333
00334
00335
00336 r__3 = (r__1 = enrmax - 1.f, dabs(r__1)), r__4 = (r__2 = enrmin - 1.f,
00337 dabs(r__2));
00338 result[2] = dmax(r__3,r__4) / ((real) (*n) * ulp);
00339
00340 return 0;
00341
00342
00343
00344 }