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