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__2 = 2;
00019 static integer c__1 = 1;
00020
00021 int slagv2_(real *a, integer *lda, real *b, integer *ldb,
00022 real *alphar, real *alphai, real *beta, real *csl, real *snl, real *
00023 csr, real *snr)
00024 {
00025
00026 integer a_dim1, a_offset, b_dim1, b_offset;
00027 real r__1, r__2, r__3, r__4, r__5, r__6;
00028
00029
00030 real r__, t, h1, h2, h3, wi, qq, rr, wr1, wr2, ulp;
00031 extern int srot_(integer *, real *, integer *, real *,
00032 integer *, real *, real *), slag2_(real *, integer *, real *,
00033 integer *, real *, real *, real *, real *, real *, real *);
00034 real anorm, bnorm, scale1, scale2;
00035 extern int slasv2_(real *, real *, real *, real *, real *
00036 , real *, real *, real *, real *);
00037 extern doublereal slapy2_(real *, real *);
00038 real ascale, bscale;
00039 extern doublereal slamch_(char *);
00040 real safmin;
00041 extern int slartg_(real *, real *, real *, real *, real *
00042 );
00043
00044
00045
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 a_dim1 = *lda;
00143 a_offset = 1 + a_dim1;
00144 a -= a_offset;
00145 b_dim1 = *ldb;
00146 b_offset = 1 + b_dim1;
00147 b -= b_offset;
00148 --alphar;
00149 --alphai;
00150 --beta;
00151
00152
00153 safmin = slamch_("S");
00154 ulp = slamch_("P");
00155
00156
00157
00158
00159 r__5 = (r__1 = a[a_dim1 + 1], dabs(r__1)) + (r__2 = a[a_dim1 + 2], dabs(
00160 r__2)), r__6 = (r__3 = a[(a_dim1 << 1) + 1], dabs(r__3)) + (r__4 =
00161 a[(a_dim1 << 1) + 2], dabs(r__4)), r__5 = max(r__5,r__6);
00162 anorm = dmax(r__5,safmin);
00163 ascale = 1.f / anorm;
00164 a[a_dim1 + 1] = ascale * a[a_dim1 + 1];
00165 a[(a_dim1 << 1) + 1] = ascale * a[(a_dim1 << 1) + 1];
00166 a[a_dim1 + 2] = ascale * a[a_dim1 + 2];
00167 a[(a_dim1 << 1) + 2] = ascale * a[(a_dim1 << 1) + 2];
00168
00169
00170
00171
00172 r__4 = (r__3 = b[b_dim1 + 1], dabs(r__3)), r__5 = (r__1 = b[(b_dim1 << 1)
00173 + 1], dabs(r__1)) + (r__2 = b[(b_dim1 << 1) + 2], dabs(r__2)),
00174 r__4 = max(r__4,r__5);
00175 bnorm = dmax(r__4,safmin);
00176 bscale = 1.f / bnorm;
00177 b[b_dim1 + 1] = bscale * b[b_dim1 + 1];
00178 b[(b_dim1 << 1) + 1] = bscale * b[(b_dim1 << 1) + 1];
00179 b[(b_dim1 << 1) + 2] = bscale * b[(b_dim1 << 1) + 2];
00180
00181
00182
00183 if ((r__1 = a[a_dim1 + 2], dabs(r__1)) <= ulp) {
00184 *csl = 1.f;
00185 *snl = 0.f;
00186 *csr = 1.f;
00187 *snr = 0.f;
00188 a[a_dim1 + 2] = 0.f;
00189 b[b_dim1 + 2] = 0.f;
00190
00191
00192
00193 } else if ((r__1 = b[b_dim1 + 1], dabs(r__1)) <= ulp) {
00194 slartg_(&a[a_dim1 + 1], &a[a_dim1 + 2], csl, snl, &r__);
00195 *csr = 1.f;
00196 *snr = 0.f;
00197 srot_(&c__2, &a[a_dim1 + 1], lda, &a[a_dim1 + 2], lda, csl, snl);
00198 srot_(&c__2, &b[b_dim1 + 1], ldb, &b[b_dim1 + 2], ldb, csl, snl);
00199 a[a_dim1 + 2] = 0.f;
00200 b[b_dim1 + 1] = 0.f;
00201 b[b_dim1 + 2] = 0.f;
00202
00203 } else if ((r__1 = b[(b_dim1 << 1) + 2], dabs(r__1)) <= ulp) {
00204 slartg_(&a[(a_dim1 << 1) + 2], &a[a_dim1 + 2], csr, snr, &t);
00205 *snr = -(*snr);
00206 srot_(&c__2, &a[a_dim1 + 1], &c__1, &a[(a_dim1 << 1) + 1], &c__1, csr,
00207 snr);
00208 srot_(&c__2, &b[b_dim1 + 1], &c__1, &b[(b_dim1 << 1) + 1], &c__1, csr,
00209 snr);
00210 *csl = 1.f;
00211 *snl = 0.f;
00212 a[a_dim1 + 2] = 0.f;
00213 b[b_dim1 + 2] = 0.f;
00214 b[(b_dim1 << 1) + 2] = 0.f;
00215
00216 } else {
00217
00218
00219
00220 slag2_(&a[a_offset], lda, &b[b_offset], ldb, &safmin, &scale1, &
00221 scale2, &wr1, &wr2, &wi);
00222
00223 if (wi == 0.f) {
00224
00225
00226
00227 h1 = scale1 * a[a_dim1 + 1] - wr1 * b[b_dim1 + 1];
00228 h2 = scale1 * a[(a_dim1 << 1) + 1] - wr1 * b[(b_dim1 << 1) + 1];
00229 h3 = scale1 * a[(a_dim1 << 1) + 2] - wr1 * b[(b_dim1 << 1) + 2];
00230
00231 rr = slapy2_(&h1, &h2);
00232 r__1 = scale1 * a[a_dim1 + 2];
00233 qq = slapy2_(&r__1, &h3);
00234
00235 if (rr > qq) {
00236
00237
00238
00239
00240 slartg_(&h2, &h1, csr, snr, &t);
00241
00242 } else {
00243
00244
00245
00246
00247 r__1 = scale1 * a[a_dim1 + 2];
00248 slartg_(&h3, &r__1, csr, snr, &t);
00249
00250 }
00251
00252 *snr = -(*snr);
00253 srot_(&c__2, &a[a_dim1 + 1], &c__1, &a[(a_dim1 << 1) + 1], &c__1,
00254 csr, snr);
00255 srot_(&c__2, &b[b_dim1 + 1], &c__1, &b[(b_dim1 << 1) + 1], &c__1,
00256 csr, snr);
00257
00258
00259
00260
00261 r__5 = (r__1 = a[a_dim1 + 1], dabs(r__1)) + (r__2 = a[(a_dim1 <<
00262 1) + 1], dabs(r__2)), r__6 = (r__3 = a[a_dim1 + 2], dabs(
00263 r__3)) + (r__4 = a[(a_dim1 << 1) + 2], dabs(r__4));
00264 h1 = dmax(r__5,r__6);
00265
00266 r__5 = (r__1 = b[b_dim1 + 1], dabs(r__1)) + (r__2 = b[(b_dim1 <<
00267 1) + 1], dabs(r__2)), r__6 = (r__3 = b[b_dim1 + 2], dabs(
00268 r__3)) + (r__4 = b[(b_dim1 << 1) + 2], dabs(r__4));
00269 h2 = dmax(r__5,r__6);
00270
00271 if (scale1 * h1 >= dabs(wr1) * h2) {
00272
00273
00274
00275 slartg_(&b[b_dim1 + 1], &b[b_dim1 + 2], csl, snl, &r__);
00276
00277 } else {
00278
00279
00280
00281 slartg_(&a[a_dim1 + 1], &a[a_dim1 + 2], csl, snl, &r__);
00282
00283 }
00284
00285 srot_(&c__2, &a[a_dim1 + 1], lda, &a[a_dim1 + 2], lda, csl, snl);
00286 srot_(&c__2, &b[b_dim1 + 1], ldb, &b[b_dim1 + 2], ldb, csl, snl);
00287
00288 a[a_dim1 + 2] = 0.f;
00289 b[b_dim1 + 2] = 0.f;
00290
00291 } else {
00292
00293
00294
00295
00296 slasv2_(&b[b_dim1 + 1], &b[(b_dim1 << 1) + 1], &b[(b_dim1 << 1) +
00297 2], &r__, &t, snr, csr, snl, csl);
00298
00299
00300
00301
00302 srot_(&c__2, &a[a_dim1 + 1], lda, &a[a_dim1 + 2], lda, csl, snl);
00303 srot_(&c__2, &b[b_dim1 + 1], ldb, &b[b_dim1 + 2], ldb, csl, snl);
00304 srot_(&c__2, &a[a_dim1 + 1], &c__1, &a[(a_dim1 << 1) + 1], &c__1,
00305 csr, snr);
00306 srot_(&c__2, &b[b_dim1 + 1], &c__1, &b[(b_dim1 << 1) + 1], &c__1,
00307 csr, snr);
00308
00309 b[b_dim1 + 2] = 0.f;
00310 b[(b_dim1 << 1) + 1] = 0.f;
00311
00312 }
00313
00314 }
00315
00316
00317
00318 a[a_dim1 + 1] = anorm * a[a_dim1 + 1];
00319 a[a_dim1 + 2] = anorm * a[a_dim1 + 2];
00320 a[(a_dim1 << 1) + 1] = anorm * a[(a_dim1 << 1) + 1];
00321 a[(a_dim1 << 1) + 2] = anorm * a[(a_dim1 << 1) + 2];
00322 b[b_dim1 + 1] = bnorm * b[b_dim1 + 1];
00323 b[b_dim1 + 2] = bnorm * b[b_dim1 + 2];
00324 b[(b_dim1 << 1) + 1] = bnorm * b[(b_dim1 << 1) + 1];
00325 b[(b_dim1 << 1) + 2] = bnorm * b[(b_dim1 << 1) + 2];
00326
00327 if (wi == 0.f) {
00328 alphar[1] = a[a_dim1 + 1];
00329 alphar[2] = a[(a_dim1 << 1) + 2];
00330 alphai[1] = 0.f;
00331 alphai[2] = 0.f;
00332 beta[1] = b[b_dim1 + 1];
00333 beta[2] = b[(b_dim1 << 1) + 2];
00334 } else {
00335 alphar[1] = anorm * wr1 / scale1 / bnorm;
00336 alphai[1] = anorm * wi / scale1 / bnorm;
00337 alphar[2] = alphar[1];
00338 alphai[2] = -alphai[1];
00339 beta[1] = 1.f;
00340 beta[2] = 1.f;
00341 }
00342
00343 return 0;
00344
00345
00346
00347 }