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 doublereal c_b20 = 0.;
00019 static integer c__2 = 2;
00020 static doublereal c_b25 = 1.;
00021 static integer c__1 = 1;
00022 static doublereal c_b30 = -1.;
00023
00024 int dget22_(char *transa, char *transe, char *transw,
00025 integer *n, doublereal *a, integer *lda, doublereal *e, integer *lde,
00026 doublereal *wr, doublereal *wi, doublereal *work, doublereal *result)
00027 {
00028
00029 integer a_dim1, a_offset, e_dim1, e_offset, i__1, i__2;
00030 doublereal d__1, d__2, d__3, d__4;
00031
00032
00033 integer j;
00034 doublereal ulp;
00035 integer ince, jcol, jvec;
00036 doublereal unfl, wmat[4] , temp1;
00037 extern int dgemm_(char *, char *, integer *, integer *,
00038 integer *, doublereal *, doublereal *, integer *, doublereal *,
00039 integer *, doublereal *, doublereal *, integer *);
00040 integer iecol;
00041 extern logical lsame_(char *, char *);
00042 integer ipair;
00043 char norma[1];
00044 doublereal anorm;
00045 char norme[1];
00046 doublereal enorm;
00047 integer ierow;
00048 extern int daxpy_(integer *, doublereal *, doublereal *,
00049 integer *, doublereal *, integer *);
00050 extern doublereal dlamch_(char *), dlange_(char *, integer *,
00051 integer *, doublereal *, integer *, doublereal *);
00052 extern int dlaset_(char *, integer *, integer *,
00053 doublereal *, doublereal *, doublereal *, integer *);
00054 doublereal enrmin, enrmax;
00055 integer itrnse;
00056 doublereal errnrm;
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
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 a_dim1 = *lda;
00177 a_offset = 1 + a_dim1;
00178 a -= a_offset;
00179 e_dim1 = *lde;
00180 e_offset = 1 + e_dim1;
00181 e -= e_offset;
00182 --wr;
00183 --wi;
00184 --work;
00185 --result;
00186
00187
00188 result[1] = 0.;
00189 result[2] = 0.;
00190 if (*n <= 0) {
00191 return 0;
00192 }
00193
00194 unfl = dlamch_("Safe minimum");
00195 ulp = dlamch_("Precision");
00196
00197 itrnse = 0;
00198 ince = 1;
00199 *(unsigned char *)norma = 'O';
00200 *(unsigned char *)norme = 'O';
00201
00202 if (lsame_(transa, "T") || lsame_(transa, "C")) {
00203 *(unsigned char *)norma = 'I';
00204 }
00205 if (lsame_(transe, "T") || lsame_(transe, "C")) {
00206 *(unsigned char *)norme = 'I';
00207 itrnse = 1;
00208 ince = *lde;
00209 }
00210
00211
00212
00213 enrmin = 1. / ulp;
00214 enrmax = 0.;
00215 if (itrnse == 0) {
00216
00217
00218
00219 ipair = 0;
00220 i__1 = *n;
00221 for (jvec = 1; jvec <= i__1; ++jvec) {
00222 temp1 = 0.;
00223 if (ipair == 0 && jvec < *n && wi[jvec] != 0.) {
00224 ipair = 1;
00225 }
00226 if (ipair == 1) {
00227
00228
00229
00230 i__2 = *n;
00231 for (j = 1; j <= i__2; ++j) {
00232
00233 d__3 = temp1, d__4 = (d__1 = e[j + jvec * e_dim1], abs(
00234 d__1)) + (d__2 = e[j + (jvec + 1) * e_dim1], abs(
00235 d__2));
00236 temp1 = max(d__3,d__4);
00237
00238 }
00239 enrmin = min(enrmin,temp1);
00240 enrmax = max(enrmax,temp1);
00241 ipair = 2;
00242 } else if (ipair == 2) {
00243 ipair = 0;
00244 } else {
00245
00246
00247
00248 i__2 = *n;
00249 for (j = 1; j <= i__2; ++j) {
00250
00251 d__2 = temp1, d__3 = (d__1 = e[j + jvec * e_dim1], abs(
00252 d__1));
00253 temp1 = max(d__2,d__3);
00254
00255 }
00256 enrmin = min(enrmin,temp1);
00257 enrmax = max(enrmax,temp1);
00258 ipair = 0;
00259 }
00260
00261 }
00262
00263 } else {
00264
00265
00266
00267 i__1 = *n;
00268 for (jvec = 1; jvec <= i__1; ++jvec) {
00269 work[jvec] = 0.;
00270
00271 }
00272
00273 i__1 = *n;
00274 for (j = 1; j <= i__1; ++j) {
00275 ipair = 0;
00276 i__2 = *n;
00277 for (jvec = 1; jvec <= i__2; ++jvec) {
00278 if (ipair == 0 && jvec < *n && wi[jvec] != 0.) {
00279 ipair = 1;
00280 }
00281 if (ipair == 1) {
00282
00283 d__3 = work[jvec], d__4 = (d__1 = e[j + jvec * e_dim1],
00284 abs(d__1)) + (d__2 = e[j + (jvec + 1) * e_dim1],
00285 abs(d__2));
00286 work[jvec] = max(d__3,d__4);
00287 work[jvec + 1] = work[jvec];
00288 } else if (ipair == 2) {
00289 ipair = 0;
00290 } else {
00291
00292 d__2 = work[jvec], d__3 = (d__1 = e[j + jvec * e_dim1],
00293 abs(d__1));
00294 work[jvec] = max(d__2,d__3);
00295 ipair = 0;
00296 }
00297
00298 }
00299
00300 }
00301
00302 i__1 = *n;
00303 for (jvec = 1; jvec <= i__1; ++jvec) {
00304
00305 d__1 = enrmin, d__2 = work[jvec];
00306 enrmin = min(d__1,d__2);
00307
00308 d__1 = enrmax, d__2 = work[jvec];
00309 enrmax = max(d__1,d__2);
00310
00311 }
00312 }
00313
00314
00315
00316
00317 d__1 = dlange_(norma, n, n, &a[a_offset], lda, &work[1]);
00318 anorm = max(d__1,unfl);
00319
00320
00321
00322
00323 d__1 = dlange_(norme, n, n, &e[e_offset], lde, &work[1]);
00324 enorm = max(d__1,ulp);
00325
00326
00327
00328
00329
00330 dlaset_("Full", n, n, &c_b20, &c_b20, &work[1], n);
00331
00332 ipair = 0;
00333 ierow = 1;
00334 iecol = 1;
00335
00336 i__1 = *n;
00337 for (jcol = 1; jcol <= i__1; ++jcol) {
00338 if (itrnse == 1) {
00339 ierow = jcol;
00340 } else {
00341 iecol = jcol;
00342 }
00343
00344 if (ipair == 0 && wi[jcol] != 0.) {
00345 ipair = 1;
00346 }
00347
00348 if (ipair == 1) {
00349 wmat[0] = wr[jcol];
00350 wmat[1] = -wi[jcol];
00351 wmat[2] = wi[jcol];
00352 wmat[3] = wr[jcol];
00353 dgemm_(transe, transw, n, &c__2, &c__2, &c_b25, &e[ierow + iecol *
00354 e_dim1], lde, wmat, &c__2, &c_b20, &work[*n * (jcol - 1)
00355 + 1], n);
00356 ipair = 2;
00357 } else if (ipair == 2) {
00358 ipair = 0;
00359
00360 } else {
00361
00362 daxpy_(n, &wr[jcol], &e[ierow + iecol * e_dim1], &ince, &work[*n *
00363 (jcol - 1) + 1], &c__1);
00364 ipair = 0;
00365 }
00366
00367
00368 }
00369
00370 dgemm_(transa, transe, n, n, n, &c_b25, &a[a_offset], lda, &e[e_offset],
00371 lde, &c_b30, &work[1], n);
00372
00373 errnrm = dlange_("One", n, n, &work[1], n, &work[*n * *n + 1])
00374 / enorm;
00375
00376
00377
00378 if (anorm > errnrm) {
00379 result[1] = errnrm / anorm / ulp;
00380 } else {
00381 if (anorm < 1.) {
00382 result[1] = min(errnrm,anorm) / anorm / ulp;
00383 } else {
00384
00385 d__1 = errnrm / anorm;
00386 result[1] = min(d__1,1.) / ulp;
00387 }
00388 }
00389
00390
00391
00392
00393 d__3 = (d__1 = enrmax - 1., abs(d__1)), d__4 = (d__2 = enrmin - 1., abs(
00394 d__2));
00395 result[2] = max(d__3,d__4) / ((doublereal) (*n) * ulp);
00396
00397 return 0;
00398
00399
00400
00401 }