00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int clags2_(logical *upper, real *a1, complex *a2, real *a3,
00017 real *b1, complex *b2, real *b3, real *csu, complex *snu, real *csv,
00018 complex *snv, real *csq, complex *snq)
00019 {
00020
00021 real r__1, r__2, r__3, r__4, r__5, r__6, r__7, r__8;
00022 complex q__1, q__2, q__3, q__4, q__5;
00023
00024
00025 double c_abs(complex *), r_imag(complex *);
00026 void r_cnjg(complex *, complex *);
00027
00028
00029 real a;
00030 complex b, c__;
00031 real d__;
00032 complex r__, d1;
00033 real s1, s2, fb, fc;
00034 complex ua11, ua12, ua21, ua22, vb11, vb12, vb21, vb22;
00035 real csl, csr, snl, snr, aua11, aua12, aua21, aua22, avb11, avb12, avb21,
00036 avb22, ua11r, ua22r, vb11r, vb22r;
00037 extern int slasv2_(real *, real *, real *, real *, real *
00038 , real *, real *, real *, real *), clartg_(complex *, complex *,
00039 real *, complex *, complex *);
00040
00041
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 if (*upper) {
00133
00134
00135
00136
00137
00138
00139 a = *a1 * *b3;
00140 d__ = *a3 * *b1;
00141 q__2.r = *b1 * a2->r, q__2.i = *b1 * a2->i;
00142 q__3.r = *a1 * b2->r, q__3.i = *a1 * b2->i;
00143 q__1.r = q__2.r - q__3.r, q__1.i = q__2.i - q__3.i;
00144 b.r = q__1.r, b.i = q__1.i;
00145 fb = c_abs(&b);
00146
00147
00148
00149
00150 d1.r = 1.f, d1.i = 0.f;
00151 if (fb != 0.f) {
00152 q__1.r = b.r / fb, q__1.i = b.i / fb;
00153 d1.r = q__1.r, d1.i = q__1.i;
00154 }
00155
00156
00157
00158
00159
00160
00161 slasv2_(&a, &fb, &d__, &s1, &s2, &snr, &csr, &snl, &csl);
00162
00163 if (dabs(csl) >= dabs(snl) || dabs(csr) >= dabs(snr)) {
00164
00165
00166
00167
00168 ua11r = csl * *a1;
00169 q__2.r = csl * a2->r, q__2.i = csl * a2->i;
00170 q__4.r = snl * d1.r, q__4.i = snl * d1.i;
00171 q__3.r = *a3 * q__4.r, q__3.i = *a3 * q__4.i;
00172 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00173 ua12.r = q__1.r, ua12.i = q__1.i;
00174
00175 vb11r = csr * *b1;
00176 q__2.r = csr * b2->r, q__2.i = csr * b2->i;
00177 q__4.r = snr * d1.r, q__4.i = snr * d1.i;
00178 q__3.r = *b3 * q__4.r, q__3.i = *b3 * q__4.i;
00179 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00180 vb12.r = q__1.r, vb12.i = q__1.i;
00181
00182 aua12 = dabs(csl) * ((r__1 = a2->r, dabs(r__1)) + (r__2 = r_imag(
00183 a2), dabs(r__2))) + dabs(snl) * dabs(*a3);
00184 avb12 = dabs(csr) * ((r__1 = b2->r, dabs(r__1)) + (r__2 = r_imag(
00185 b2), dabs(r__2))) + dabs(snr) * dabs(*b3);
00186
00187
00188
00189 if (dabs(ua11r) + ((r__1 = ua12.r, dabs(r__1)) + (r__2 = r_imag(&
00190 ua12), dabs(r__2))) == 0.f) {
00191 q__2.r = vb11r, q__2.i = 0.f;
00192 q__1.r = -q__2.r, q__1.i = -q__2.i;
00193 r_cnjg(&q__3, &vb12);
00194 clartg_(&q__1, &q__3, csq, snq, &r__);
00195 } else if (dabs(vb11r) + ((r__1 = vb12.r, dabs(r__1)) + (r__2 =
00196 r_imag(&vb12), dabs(r__2))) == 0.f) {
00197 q__2.r = ua11r, q__2.i = 0.f;
00198 q__1.r = -q__2.r, q__1.i = -q__2.i;
00199 r_cnjg(&q__3, &ua12);
00200 clartg_(&q__1, &q__3, csq, snq, &r__);
00201 } else if (aua12 / (dabs(ua11r) + ((r__1 = ua12.r, dabs(r__1)) + (
00202 r__2 = r_imag(&ua12), dabs(r__2)))) <= avb12 / (dabs(
00203 vb11r) + ((r__3 = vb12.r, dabs(r__3)) + (r__4 = r_imag(&
00204 vb12), dabs(r__4))))) {
00205 q__2.r = ua11r, q__2.i = 0.f;
00206 q__1.r = -q__2.r, q__1.i = -q__2.i;
00207 r_cnjg(&q__3, &ua12);
00208 clartg_(&q__1, &q__3, csq, snq, &r__);
00209 } else {
00210 q__2.r = vb11r, q__2.i = 0.f;
00211 q__1.r = -q__2.r, q__1.i = -q__2.i;
00212 r_cnjg(&q__3, &vb12);
00213 clartg_(&q__1, &q__3, csq, snq, &r__);
00214 }
00215
00216 *csu = csl;
00217 q__2.r = -d1.r, q__2.i = -d1.i;
00218 q__1.r = snl * q__2.r, q__1.i = snl * q__2.i;
00219 snu->r = q__1.r, snu->i = q__1.i;
00220 *csv = csr;
00221 q__2.r = -d1.r, q__2.i = -d1.i;
00222 q__1.r = snr * q__2.r, q__1.i = snr * q__2.i;
00223 snv->r = q__1.r, snv->i = q__1.i;
00224
00225 } else {
00226
00227
00228
00229
00230 r_cnjg(&q__4, &d1);
00231 q__3.r = -q__4.r, q__3.i = -q__4.i;
00232 q__2.r = snl * q__3.r, q__2.i = snl * q__3.i;
00233 q__1.r = *a1 * q__2.r, q__1.i = *a1 * q__2.i;
00234 ua21.r = q__1.r, ua21.i = q__1.i;
00235 r_cnjg(&q__5, &d1);
00236 q__4.r = -q__5.r, q__4.i = -q__5.i;
00237 q__3.r = snl * q__4.r, q__3.i = snl * q__4.i;
00238 q__2.r = q__3.r * a2->r - q__3.i * a2->i, q__2.i = q__3.r * a2->i
00239 + q__3.i * a2->r;
00240 r__1 = csl * *a3;
00241 q__1.r = q__2.r + r__1, q__1.i = q__2.i;
00242 ua22.r = q__1.r, ua22.i = q__1.i;
00243
00244 r_cnjg(&q__4, &d1);
00245 q__3.r = -q__4.r, q__3.i = -q__4.i;
00246 q__2.r = snr * q__3.r, q__2.i = snr * q__3.i;
00247 q__1.r = *b1 * q__2.r, q__1.i = *b1 * q__2.i;
00248 vb21.r = q__1.r, vb21.i = q__1.i;
00249 r_cnjg(&q__5, &d1);
00250 q__4.r = -q__5.r, q__4.i = -q__5.i;
00251 q__3.r = snr * q__4.r, q__3.i = snr * q__4.i;
00252 q__2.r = q__3.r * b2->r - q__3.i * b2->i, q__2.i = q__3.r * b2->i
00253 + q__3.i * b2->r;
00254 r__1 = csr * *b3;
00255 q__1.r = q__2.r + r__1, q__1.i = q__2.i;
00256 vb22.r = q__1.r, vb22.i = q__1.i;
00257
00258 aua22 = dabs(snl) * ((r__1 = a2->r, dabs(r__1)) + (r__2 = r_imag(
00259 a2), dabs(r__2))) + dabs(csl) * dabs(*a3);
00260 avb22 = dabs(snr) * ((r__1 = b2->r, dabs(r__1)) + (r__2 = r_imag(
00261 b2), dabs(r__2))) + dabs(csr) * dabs(*b3);
00262
00263
00264
00265 if ((r__1 = ua21.r, dabs(r__1)) + (r__2 = r_imag(&ua21), dabs(
00266 r__2)) + ((r__3 = ua22.r, dabs(r__3)) + (r__4 = r_imag(&
00267 ua22), dabs(r__4))) == 0.f) {
00268 r_cnjg(&q__2, &vb21);
00269 q__1.r = -q__2.r, q__1.i = -q__2.i;
00270 r_cnjg(&q__3, &vb22);
00271 clartg_(&q__1, &q__3, csq, snq, &r__);
00272 } else if ((r__1 = vb21.r, dabs(r__1)) + (r__2 = r_imag(&vb21),
00273 dabs(r__2)) + c_abs(&vb22) == 0.f) {
00274 r_cnjg(&q__2, &ua21);
00275 q__1.r = -q__2.r, q__1.i = -q__2.i;
00276 r_cnjg(&q__3, &ua22);
00277 clartg_(&q__1, &q__3, csq, snq, &r__);
00278 } else if (aua22 / ((r__1 = ua21.r, dabs(r__1)) + (r__2 = r_imag(&
00279 ua21), dabs(r__2)) + ((r__3 = ua22.r, dabs(r__3)) + (r__4
00280 = r_imag(&ua22), dabs(r__4)))) <= avb22 / ((r__5 = vb21.r,
00281 dabs(r__5)) + (r__6 = r_imag(&vb21), dabs(r__6)) + ((
00282 r__7 = vb22.r, dabs(r__7)) + (r__8 = r_imag(&vb22), dabs(
00283 r__8))))) {
00284 r_cnjg(&q__2, &ua21);
00285 q__1.r = -q__2.r, q__1.i = -q__2.i;
00286 r_cnjg(&q__3, &ua22);
00287 clartg_(&q__1, &q__3, csq, snq, &r__);
00288 } else {
00289 r_cnjg(&q__2, &vb21);
00290 q__1.r = -q__2.r, q__1.i = -q__2.i;
00291 r_cnjg(&q__3, &vb22);
00292 clartg_(&q__1, &q__3, csq, snq, &r__);
00293 }
00294
00295 *csu = snl;
00296 q__1.r = csl * d1.r, q__1.i = csl * d1.i;
00297 snu->r = q__1.r, snu->i = q__1.i;
00298 *csv = snr;
00299 q__1.r = csr * d1.r, q__1.i = csr * d1.i;
00300 snv->r = q__1.r, snv->i = q__1.i;
00301
00302 }
00303
00304 } else {
00305
00306
00307
00308
00309
00310
00311 a = *a1 * *b3;
00312 d__ = *a3 * *b1;
00313 q__2.r = *b3 * a2->r, q__2.i = *b3 * a2->i;
00314 q__3.r = *a3 * b2->r, q__3.i = *a3 * b2->i;
00315 q__1.r = q__2.r - q__3.r, q__1.i = q__2.i - q__3.i;
00316 c__.r = q__1.r, c__.i = q__1.i;
00317 fc = c_abs(&c__);
00318
00319
00320
00321
00322 d1.r = 1.f, d1.i = 0.f;
00323 if (fc != 0.f) {
00324 q__1.r = c__.r / fc, q__1.i = c__.i / fc;
00325 d1.r = q__1.r, d1.i = q__1.i;
00326 }
00327
00328
00329
00330
00331
00332
00333 slasv2_(&a, &fc, &d__, &s1, &s2, &snr, &csr, &snl, &csl);
00334
00335 if (dabs(csr) >= dabs(snr) || dabs(csl) >= dabs(snl)) {
00336
00337
00338
00339
00340 q__4.r = -d1.r, q__4.i = -d1.i;
00341 q__3.r = snr * q__4.r, q__3.i = snr * q__4.i;
00342 q__2.r = *a1 * q__3.r, q__2.i = *a1 * q__3.i;
00343 q__5.r = csr * a2->r, q__5.i = csr * a2->i;
00344 q__1.r = q__2.r + q__5.r, q__1.i = q__2.i + q__5.i;
00345 ua21.r = q__1.r, ua21.i = q__1.i;
00346 ua22r = csr * *a3;
00347
00348 q__4.r = -d1.r, q__4.i = -d1.i;
00349 q__3.r = snl * q__4.r, q__3.i = snl * q__4.i;
00350 q__2.r = *b1 * q__3.r, q__2.i = *b1 * q__3.i;
00351 q__5.r = csl * b2->r, q__5.i = csl * b2->i;
00352 q__1.r = q__2.r + q__5.r, q__1.i = q__2.i + q__5.i;
00353 vb21.r = q__1.r, vb21.i = q__1.i;
00354 vb22r = csl * *b3;
00355
00356 aua21 = dabs(snr) * dabs(*a1) + dabs(csr) * ((r__1 = a2->r, dabs(
00357 r__1)) + (r__2 = r_imag(a2), dabs(r__2)));
00358 avb21 = dabs(snl) * dabs(*b1) + dabs(csl) * ((r__1 = b2->r, dabs(
00359 r__1)) + (r__2 = r_imag(b2), dabs(r__2)));
00360
00361
00362
00363 if ((r__1 = ua21.r, dabs(r__1)) + (r__2 = r_imag(&ua21), dabs(
00364 r__2)) + dabs(ua22r) == 0.f) {
00365 q__1.r = vb22r, q__1.i = 0.f;
00366 clartg_(&q__1, &vb21, csq, snq, &r__);
00367 } else if ((r__1 = vb21.r, dabs(r__1)) + (r__2 = r_imag(&vb21),
00368 dabs(r__2)) + dabs(vb22r) == 0.f) {
00369 q__1.r = ua22r, q__1.i = 0.f;
00370 clartg_(&q__1, &ua21, csq, snq, &r__);
00371 } else if (aua21 / ((r__1 = ua21.r, dabs(r__1)) + (r__2 = r_imag(&
00372 ua21), dabs(r__2)) + dabs(ua22r)) <= avb21 / ((r__3 =
00373 vb21.r, dabs(r__3)) + (r__4 = r_imag(&vb21), dabs(r__4))
00374 + dabs(vb22r))) {
00375 q__1.r = ua22r, q__1.i = 0.f;
00376 clartg_(&q__1, &ua21, csq, snq, &r__);
00377 } else {
00378 q__1.r = vb22r, q__1.i = 0.f;
00379 clartg_(&q__1, &vb21, csq, snq, &r__);
00380 }
00381
00382 *csu = csr;
00383 r_cnjg(&q__3, &d1);
00384 q__2.r = -q__3.r, q__2.i = -q__3.i;
00385 q__1.r = snr * q__2.r, q__1.i = snr * q__2.i;
00386 snu->r = q__1.r, snu->i = q__1.i;
00387 *csv = csl;
00388 r_cnjg(&q__3, &d1);
00389 q__2.r = -q__3.r, q__2.i = -q__3.i;
00390 q__1.r = snl * q__2.r, q__1.i = snl * q__2.i;
00391 snv->r = q__1.r, snv->i = q__1.i;
00392
00393 } else {
00394
00395
00396
00397
00398 r__1 = csr * *a1;
00399 r_cnjg(&q__4, &d1);
00400 q__3.r = snr * q__4.r, q__3.i = snr * q__4.i;
00401 q__2.r = q__3.r * a2->r - q__3.i * a2->i, q__2.i = q__3.r * a2->i
00402 + q__3.i * a2->r;
00403 q__1.r = r__1 + q__2.r, q__1.i = q__2.i;
00404 ua11.r = q__1.r, ua11.i = q__1.i;
00405 r_cnjg(&q__3, &d1);
00406 q__2.r = snr * q__3.r, q__2.i = snr * q__3.i;
00407 q__1.r = *a3 * q__2.r, q__1.i = *a3 * q__2.i;
00408 ua12.r = q__1.r, ua12.i = q__1.i;
00409
00410 r__1 = csl * *b1;
00411 r_cnjg(&q__4, &d1);
00412 q__3.r = snl * q__4.r, q__3.i = snl * q__4.i;
00413 q__2.r = q__3.r * b2->r - q__3.i * b2->i, q__2.i = q__3.r * b2->i
00414 + q__3.i * b2->r;
00415 q__1.r = r__1 + q__2.r, q__1.i = q__2.i;
00416 vb11.r = q__1.r, vb11.i = q__1.i;
00417 r_cnjg(&q__3, &d1);
00418 q__2.r = snl * q__3.r, q__2.i = snl * q__3.i;
00419 q__1.r = *b3 * q__2.r, q__1.i = *b3 * q__2.i;
00420 vb12.r = q__1.r, vb12.i = q__1.i;
00421
00422 aua11 = dabs(csr) * dabs(*a1) + dabs(snr) * ((r__1 = a2->r, dabs(
00423 r__1)) + (r__2 = r_imag(a2), dabs(r__2)));
00424 avb11 = dabs(csl) * dabs(*b1) + dabs(snl) * ((r__1 = b2->r, dabs(
00425 r__1)) + (r__2 = r_imag(b2), dabs(r__2)));
00426
00427
00428
00429 if ((r__1 = ua11.r, dabs(r__1)) + (r__2 = r_imag(&ua11), dabs(
00430 r__2)) + ((r__3 = ua12.r, dabs(r__3)) + (r__4 = r_imag(&
00431 ua12), dabs(r__4))) == 0.f) {
00432 clartg_(&vb12, &vb11, csq, snq, &r__);
00433 } else if ((r__1 = vb11.r, dabs(r__1)) + (r__2 = r_imag(&vb11),
00434 dabs(r__2)) + ((r__3 = vb12.r, dabs(r__3)) + (r__4 =
00435 r_imag(&vb12), dabs(r__4))) == 0.f) {
00436 clartg_(&ua12, &ua11, csq, snq, &r__);
00437 } else if (aua11 / ((r__1 = ua11.r, dabs(r__1)) + (r__2 = r_imag(&
00438 ua11), dabs(r__2)) + ((r__3 = ua12.r, dabs(r__3)) + (r__4
00439 = r_imag(&ua12), dabs(r__4)))) <= avb11 / ((r__5 = vb11.r,
00440 dabs(r__5)) + (r__6 = r_imag(&vb11), dabs(r__6)) + ((
00441 r__7 = vb12.r, dabs(r__7)) + (r__8 = r_imag(&vb12), dabs(
00442 r__8))))) {
00443 clartg_(&ua12, &ua11, csq, snq, &r__);
00444 } else {
00445 clartg_(&vb12, &vb11, csq, snq, &r__);
00446 }
00447
00448 *csu = snr;
00449 r_cnjg(&q__2, &d1);
00450 q__1.r = csr * q__2.r, q__1.i = csr * q__2.i;
00451 snu->r = q__1.r, snu->i = q__1.i;
00452 *csv = snl;
00453 r_cnjg(&q__2, &d1);
00454 q__1.r = csl * q__2.r, q__1.i = csl * q__2.i;
00455 snv->r = q__1.r, snv->i = q__1.i;
00456
00457 }
00458
00459 }
00460
00461 return 0;
00462
00463
00464
00465 }