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