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_b12 = 0.;
00020 static doublereal c_b15 = 1.;
00021
00022 int dget52_(logical *left, integer *n, doublereal *a,
00023 integer *lda, doublereal *b, integer *ldb, doublereal *e, integer *
00024 lde, doublereal *alphar, doublereal *alphai, doublereal *beta,
00025 doublereal *work, doublereal *result)
00026 {
00027
00028 integer a_dim1, a_offset, b_dim1, b_offset, e_dim1, e_offset, i__1, i__2;
00029 doublereal d__1, d__2, d__3, d__4;
00030
00031
00032 integer j;
00033 doublereal ulp;
00034 integer jvec;
00035 doublereal temp1, acoef, scale, abmax, salfi, sbeta;
00036 extern int dgemv_(char *, integer *, integer *,
00037 doublereal *, doublereal *, integer *, doublereal *, integer *,
00038 doublereal *, doublereal *, integer *);
00039 doublereal salfr, anorm, bnorm, enorm;
00040 char trans[1];
00041 doublereal bcoefi;
00042 extern doublereal dlamch_(char *), dlange_(char *, integer *,
00043 integer *, doublereal *, integer *, doublereal *);
00044 doublereal bcoefr, alfmax, safmin;
00045 char normab[1];
00046 doublereal safmax, betmax, enrmer;
00047 logical ilcplx;
00048 doublereal errnrm;
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
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
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194 a_dim1 = *lda;
00195 a_offset = 1 + a_dim1;
00196 a -= a_offset;
00197 b_dim1 = *ldb;
00198 b_offset = 1 + b_dim1;
00199 b -= b_offset;
00200 e_dim1 = *lde;
00201 e_offset = 1 + e_dim1;
00202 e -= e_offset;
00203 --alphar;
00204 --alphai;
00205 --beta;
00206 --work;
00207 --result;
00208
00209
00210 result[1] = 0.;
00211 result[2] = 0.;
00212 if (*n <= 0) {
00213 return 0;
00214 }
00215
00216 safmin = dlamch_("Safe minimum");
00217 safmax = 1. / safmin;
00218 ulp = dlamch_("Epsilon") * dlamch_("Base");
00219
00220 if (*left) {
00221 *(unsigned char *)trans = 'T';
00222 *(unsigned char *)normab = 'I';
00223 } else {
00224 *(unsigned char *)trans = 'N';
00225 *(unsigned char *)normab = 'O';
00226 }
00227
00228
00229
00230
00231 d__1 = dlange_(normab, n, n, &a[a_offset], lda, &work[1]);
00232 anorm = max(d__1,safmin);
00233
00234 d__1 = dlange_(normab, n, n, &b[b_offset], ldb, &work[1]);
00235 bnorm = max(d__1,safmin);
00236
00237 d__1 = dlange_("O", n, n, &e[e_offset], lde, &work[1]);
00238 enorm = max(d__1,ulp);
00239 alfmax = safmax / max(1.,bnorm);
00240 betmax = safmax / max(1.,anorm);
00241
00242
00243
00244
00245 ilcplx = FALSE_;
00246 i__1 = *n;
00247 for (jvec = 1; jvec <= i__1; ++jvec) {
00248 if (ilcplx) {
00249
00250
00251
00252 ilcplx = FALSE_;
00253 } else {
00254 salfr = alphar[jvec];
00255 salfi = alphai[jvec];
00256 sbeta = beta[jvec];
00257 if (salfi == 0.) {
00258
00259
00260
00261
00262 d__1 = abs(salfr), d__2 = abs(sbeta);
00263 abmax = max(d__1,d__2);
00264 if (abs(salfr) > alfmax || abs(sbeta) > betmax || abmax < 1.)
00265 {
00266 scale = 1. / max(abmax,safmin);
00267 salfr = scale * salfr;
00268 sbeta = scale * sbeta;
00269 }
00270
00271 d__1 = abs(salfr) * bnorm, d__2 = abs(sbeta) * anorm, d__1 =
00272 max(d__1,d__2);
00273 scale = 1. / max(d__1,safmin);
00274 acoef = scale * sbeta;
00275 bcoefr = scale * salfr;
00276 dgemv_(trans, n, n, &acoef, &a[a_offset], lda, &e[jvec *
00277 e_dim1 + 1], &c__1, &c_b12, &work[*n * (jvec - 1) + 1]
00278 , &c__1);
00279 d__1 = -bcoefr;
00280 dgemv_(trans, n, n, &d__1, &b[b_offset], lda, &e[jvec *
00281 e_dim1 + 1], &c__1, &c_b15, &work[*n * (jvec - 1) + 1]
00282 , &c__1);
00283 } else {
00284
00285
00286
00287 ilcplx = TRUE_;
00288 if (jvec == *n) {
00289 result[1] = 10. / ulp;
00290 return 0;
00291 }
00292
00293 d__1 = abs(salfr) + abs(salfi), d__2 = abs(sbeta);
00294 abmax = max(d__1,d__2);
00295 if (abs(salfr) + abs(salfi) > alfmax || abs(sbeta) > betmax ||
00296 abmax < 1.) {
00297 scale = 1. / max(abmax,safmin);
00298 salfr = scale * salfr;
00299 salfi = scale * salfi;
00300 sbeta = scale * sbeta;
00301 }
00302
00303 d__1 = (abs(salfr) + abs(salfi)) * bnorm, d__2 = abs(sbeta) *
00304 anorm, d__1 = max(d__1,d__2);
00305 scale = 1. / max(d__1,safmin);
00306 acoef = scale * sbeta;
00307 bcoefr = scale * salfr;
00308 bcoefi = scale * salfi;
00309 if (*left) {
00310 bcoefi = -bcoefi;
00311 }
00312
00313 dgemv_(trans, n, n, &acoef, &a[a_offset], lda, &e[jvec *
00314 e_dim1 + 1], &c__1, &c_b12, &work[*n * (jvec - 1) + 1]
00315 , &c__1);
00316 d__1 = -bcoefr;
00317 dgemv_(trans, n, n, &d__1, &b[b_offset], lda, &e[jvec *
00318 e_dim1 + 1], &c__1, &c_b15, &work[*n * (jvec - 1) + 1]
00319 , &c__1);
00320 dgemv_(trans, n, n, &bcoefi, &b[b_offset], lda, &e[(jvec + 1)
00321 * e_dim1 + 1], &c__1, &c_b15, &work[*n * (jvec - 1) +
00322 1], &c__1);
00323
00324 dgemv_(trans, n, n, &acoef, &a[a_offset], lda, &e[(jvec + 1) *
00325 e_dim1 + 1], &c__1, &c_b12, &work[*n * jvec + 1], &
00326 c__1);
00327 d__1 = -bcoefi;
00328 dgemv_(trans, n, n, &d__1, &b[b_offset], lda, &e[jvec *
00329 e_dim1 + 1], &c__1, &c_b15, &work[*n * jvec + 1], &
00330 c__1);
00331 d__1 = -bcoefr;
00332 dgemv_(trans, n, n, &d__1, &b[b_offset], lda, &e[(jvec + 1) *
00333 e_dim1 + 1], &c__1, &c_b15, &work[*n * jvec + 1], &
00334 c__1);
00335 }
00336 }
00337
00338 }
00339
00340
00341 i__1 = *n;
00342 errnrm = dlange_("One", n, n, &work[1], n, &work[i__1 * i__1 + 1]) / enorm;
00343
00344
00345
00346 result[1] = errnrm / ulp;
00347
00348
00349
00350 enrmer = 0.;
00351 ilcplx = FALSE_;
00352 i__1 = *n;
00353 for (jvec = 1; jvec <= i__1; ++jvec) {
00354 if (ilcplx) {
00355 ilcplx = FALSE_;
00356 } else {
00357 temp1 = 0.;
00358 if (alphai[jvec] == 0.) {
00359 i__2 = *n;
00360 for (j = 1; j <= i__2; ++j) {
00361
00362 d__2 = temp1, d__3 = (d__1 = e[j + jvec * e_dim1], abs(
00363 d__1));
00364 temp1 = max(d__2,d__3);
00365
00366 }
00367
00368 d__1 = enrmer, d__2 = temp1 - 1.;
00369 enrmer = max(d__1,d__2);
00370 } else {
00371 ilcplx = TRUE_;
00372 i__2 = *n;
00373 for (j = 1; j <= i__2; ++j) {
00374
00375 d__3 = temp1, d__4 = (d__1 = e[j + jvec * e_dim1], abs(
00376 d__1)) + (d__2 = e[j + (jvec + 1) * e_dim1], abs(
00377 d__2));
00378 temp1 = max(d__3,d__4);
00379
00380 }
00381
00382 d__1 = enrmer, d__2 = temp1 - 1.;
00383 enrmer = max(d__1,d__2);
00384 }
00385 }
00386
00387 }
00388
00389
00390
00391 result[2] = enrmer / ((doublereal) (*n) * ulp);
00392
00393 return 0;
00394
00395
00396
00397 }