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 static integer c__1 = 1;
00021
00022 int cget52_(logical *left, integer *n, complex *a, integer *
00023 lda, complex *b, integer *ldb, complex *e, integer *lde, complex *
00024 alpha, complex *beta, complex *work, real *rwork, real *result)
00025 {
00026
00027 integer a_dim1, a_offset, b_dim1, b_offset, e_dim1, e_offset, i__1, i__2,
00028 i__3;
00029 real r__1, r__2, r__3, r__4, r__5, r__6;
00030 complex q__1;
00031
00032
00033 double r_imag(complex *);
00034 void r_cnjg(complex *, complex *);
00035
00036
00037 integer j;
00038 real ulp;
00039 integer jvec;
00040 real temp1;
00041 complex betai;
00042 real scale, abmax;
00043 extern int cgemv_(char *, integer *, integer *, complex *
00044 , complex *, integer *, complex *, integer *, complex *, complex *
00045 , integer *);
00046 real anorm, bnorm, enorm;
00047 char trans[1];
00048 complex acoeff, bcoeff;
00049 extern doublereal clange_(char *, integer *, integer *, complex *,
00050 integer *, real *);
00051 complex alphai;
00052 extern doublereal slamch_(char *);
00053 real alfmax, safmin;
00054 char normab[1];
00055 real safmax, betmax, enrmer, errnrm;
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 a_dim1 = *lda;
00168 a_offset = 1 + a_dim1;
00169 a -= a_offset;
00170 b_dim1 = *ldb;
00171 b_offset = 1 + b_dim1;
00172 b -= b_offset;
00173 e_dim1 = *lde;
00174 e_offset = 1 + e_dim1;
00175 e -= e_offset;
00176 --alpha;
00177 --beta;
00178 --work;
00179 --rwork;
00180 --result;
00181
00182
00183 result[1] = 0.f;
00184 result[2] = 0.f;
00185 if (*n <= 0) {
00186 return 0;
00187 }
00188
00189 safmin = slamch_("Safe minimum");
00190 safmax = 1.f / safmin;
00191 ulp = slamch_("Epsilon") * slamch_("Base");
00192
00193 if (*left) {
00194 *(unsigned char *)trans = 'C';
00195 *(unsigned char *)normab = 'I';
00196 } else {
00197 *(unsigned char *)trans = 'N';
00198 *(unsigned char *)normab = 'O';
00199 }
00200
00201
00202
00203
00204 r__1 = clange_(normab, n, n, &a[a_offset], lda, &rwork[1]);
00205 anorm = dmax(r__1,safmin);
00206
00207 r__1 = clange_(normab, n, n, &b[b_offset], ldb, &rwork[1]);
00208 bnorm = dmax(r__1,safmin);
00209
00210 r__1 = clange_("O", n, n, &e[e_offset], lde, &rwork[1]);
00211 enorm = dmax(r__1,ulp);
00212 alfmax = safmax / dmax(1.f,bnorm);
00213 betmax = safmax / dmax(1.f,anorm);
00214
00215
00216
00217
00218 i__1 = *n;
00219 for (jvec = 1; jvec <= i__1; ++jvec) {
00220 i__2 = jvec;
00221 alphai.r = alpha[i__2].r, alphai.i = alpha[i__2].i;
00222 i__2 = jvec;
00223 betai.r = beta[i__2].r, betai.i = beta[i__2].i;
00224
00225 r__5 = (r__1 = alphai.r, dabs(r__1)) + (r__2 = r_imag(&alphai), dabs(
00226 r__2)), r__6 = (r__3 = betai.r, dabs(r__3)) + (r__4 = r_imag(&
00227 betai), dabs(r__4));
00228 abmax = dmax(r__5,r__6);
00229 if ((r__1 = alphai.r, dabs(r__1)) + (r__2 = r_imag(&alphai), dabs(
00230 r__2)) > alfmax || (r__3 = betai.r, dabs(r__3)) + (r__4 =
00231 r_imag(&betai), dabs(r__4)) > betmax || abmax < 1.f) {
00232 scale = 1.f / dmax(abmax,safmin);
00233 q__1.r = scale * alphai.r, q__1.i = scale * alphai.i;
00234 alphai.r = q__1.r, alphai.i = q__1.i;
00235 q__1.r = scale * betai.r, q__1.i = scale * betai.i;
00236 betai.r = q__1.r, betai.i = q__1.i;
00237 }
00238
00239 r__5 = ((r__1 = alphai.r, dabs(r__1)) + (r__2 = r_imag(&alphai), dabs(
00240 r__2))) * bnorm, r__6 = ((r__3 = betai.r, dabs(r__3)) + (r__4
00241 = r_imag(&betai), dabs(r__4))) * anorm, r__5 = max(r__5,r__6);
00242 scale = 1.f / dmax(r__5,safmin);
00243 q__1.r = scale * betai.r, q__1.i = scale * betai.i;
00244 acoeff.r = q__1.r, acoeff.i = q__1.i;
00245 q__1.r = scale * alphai.r, q__1.i = scale * alphai.i;
00246 bcoeff.r = q__1.r, bcoeff.i = q__1.i;
00247 if (*left) {
00248 r_cnjg(&q__1, &acoeff);
00249 acoeff.r = q__1.r, acoeff.i = q__1.i;
00250 r_cnjg(&q__1, &bcoeff);
00251 bcoeff.r = q__1.r, bcoeff.i = q__1.i;
00252 }
00253 cgemv_(trans, n, n, &acoeff, &a[a_offset], lda, &e[jvec * e_dim1 + 1],
00254 &c__1, &c_b1, &work[*n * (jvec - 1) + 1], &c__1);
00255 q__1.r = -bcoeff.r, q__1.i = -bcoeff.i;
00256 cgemv_(trans, n, n, &q__1, &b[b_offset], lda, &e[jvec * e_dim1 + 1], &
00257 c__1, &c_b2, &work[*n * (jvec - 1) + 1], &c__1);
00258
00259 }
00260
00261 errnrm = clange_("One", n, n, &work[1], n, &rwork[1]) / enorm;
00262
00263
00264
00265 result[1] = errnrm / ulp;
00266
00267
00268
00269 enrmer = 0.f;
00270 i__1 = *n;
00271 for (jvec = 1; jvec <= i__1; ++jvec) {
00272 temp1 = 0.f;
00273 i__2 = *n;
00274 for (j = 1; j <= i__2; ++j) {
00275
00276 i__3 = j + jvec * e_dim1;
00277 r__3 = temp1, r__4 = (r__1 = e[i__3].r, dabs(r__1)) + (r__2 =
00278 r_imag(&e[j + jvec * e_dim1]), dabs(r__2));
00279 temp1 = dmax(r__3,r__4);
00280
00281 }
00282
00283 r__1 = enrmer, r__2 = temp1 - 1.f;
00284 enrmer = dmax(r__1,r__2);
00285
00286 }
00287
00288
00289
00290 result[2] = enrmer / ((real) (*n) * ulp);
00291
00292 return 0;
00293
00294
00295
00296 }