00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int dlags2_(logical *upper, doublereal *a1, doublereal *a2,
00017 doublereal *a3, doublereal *b1, doublereal *b2, doublereal *b3,
00018 doublereal *csu, doublereal *snu, doublereal *csv, doublereal *snv,
00019 doublereal *csq, doublereal *snq)
00020 {
00021
00022 doublereal d__1;
00023
00024
00025 doublereal a, b, c__, d__, r__, s1, s2, ua11, ua12, ua21, ua22, vb11,
00026 vb12, vb21, vb22, csl, csr, snl, snr, aua11, aua12, aua21, aua22,
00027 avb11, avb12, avb21, avb22, ua11r, ua22r, vb11r, vb22r;
00028 extern int dlasv2_(doublereal *, doublereal *,
00029 doublereal *, doublereal *, doublereal *, doublereal *,
00030 doublereal *, doublereal *, doublereal *), dlartg_(doublereal *,
00031 doublereal *, doublereal *, doublereal *, doublereal *);
00032
00033
00034
00035
00036
00037
00038
00039
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 if (*upper) {
00113
00114
00115
00116
00117
00118
00119 a = *a1 * *b3;
00120 d__ = *a3 * *b1;
00121 b = *a2 * *b1 - *a1 * *b2;
00122
00123
00124
00125
00126
00127
00128 dlasv2_(&a, &b, &d__, &s1, &s2, &snr, &csr, &snl, &csl);
00129
00130 if (abs(csl) >= abs(snl) || abs(csr) >= abs(snr)) {
00131
00132
00133
00134
00135 ua11r = csl * *a1;
00136 ua12 = csl * *a2 + snl * *a3;
00137
00138 vb11r = csr * *b1;
00139 vb12 = csr * *b2 + snr * *b3;
00140
00141 aua12 = abs(csl) * abs(*a2) + abs(snl) * abs(*a3);
00142 avb12 = abs(csr) * abs(*b2) + abs(snr) * abs(*b3);
00143
00144
00145
00146 if (abs(ua11r) + abs(ua12) != 0.) {
00147 if (aua12 / (abs(ua11r) + abs(ua12)) <= avb12 / (abs(vb11r) +
00148 abs(vb12))) {
00149 d__1 = -ua11r;
00150 dlartg_(&d__1, &ua12, csq, snq, &r__);
00151 } else {
00152 d__1 = -vb11r;
00153 dlartg_(&d__1, &vb12, csq, snq, &r__);
00154 }
00155 } else {
00156 d__1 = -vb11r;
00157 dlartg_(&d__1, &vb12, csq, snq, &r__);
00158 }
00159
00160 *csu = csl;
00161 *snu = -snl;
00162 *csv = csr;
00163 *snv = -snr;
00164
00165 } else {
00166
00167
00168
00169
00170 ua21 = -snl * *a1;
00171 ua22 = -snl * *a2 + csl * *a3;
00172
00173 vb21 = -snr * *b1;
00174 vb22 = -snr * *b2 + csr * *b3;
00175
00176 aua22 = abs(snl) * abs(*a2) + abs(csl) * abs(*a3);
00177 avb22 = abs(snr) * abs(*b2) + abs(csr) * abs(*b3);
00178
00179
00180
00181 if (abs(ua21) + abs(ua22) != 0.) {
00182 if (aua22 / (abs(ua21) + abs(ua22)) <= avb22 / (abs(vb21) +
00183 abs(vb22))) {
00184 d__1 = -ua21;
00185 dlartg_(&d__1, &ua22, csq, snq, &r__);
00186 } else {
00187 d__1 = -vb21;
00188 dlartg_(&d__1, &vb22, csq, snq, &r__);
00189 }
00190 } else {
00191 d__1 = -vb21;
00192 dlartg_(&d__1, &vb22, csq, snq, &r__);
00193 }
00194
00195 *csu = snl;
00196 *snu = csl;
00197 *csv = snr;
00198 *snv = csr;
00199
00200 }
00201
00202 } else {
00203
00204
00205
00206
00207
00208
00209 a = *a1 * *b3;
00210 d__ = *a3 * *b1;
00211 c__ = *a2 * *b3 - *a3 * *b2;
00212
00213
00214
00215
00216
00217
00218 dlasv2_(&a, &c__, &d__, &s1, &s2, &snr, &csr, &snl, &csl);
00219
00220 if (abs(csr) >= abs(snr) || abs(csl) >= abs(snl)) {
00221
00222
00223
00224
00225 ua21 = -snr * *a1 + csr * *a2;
00226 ua22r = csr * *a3;
00227
00228 vb21 = -snl * *b1 + csl * *b2;
00229 vb22r = csl * *b3;
00230
00231 aua21 = abs(snr) * abs(*a1) + abs(csr) * abs(*a2);
00232 avb21 = abs(snl) * abs(*b1) + abs(csl) * abs(*b2);
00233
00234
00235
00236 if (abs(ua21) + abs(ua22r) != 0.) {
00237 if (aua21 / (abs(ua21) + abs(ua22r)) <= avb21 / (abs(vb21) +
00238 abs(vb22r))) {
00239 dlartg_(&ua22r, &ua21, csq, snq, &r__);
00240 } else {
00241 dlartg_(&vb22r, &vb21, csq, snq, &r__);
00242 }
00243 } else {
00244 dlartg_(&vb22r, &vb21, csq, snq, &r__);
00245 }
00246
00247 *csu = csr;
00248 *snu = -snr;
00249 *csv = csl;
00250 *snv = -snl;
00251
00252 } else {
00253
00254
00255
00256
00257 ua11 = csr * *a1 + snr * *a2;
00258 ua12 = snr * *a3;
00259
00260 vb11 = csl * *b1 + snl * *b2;
00261 vb12 = snl * *b3;
00262
00263 aua11 = abs(csr) * abs(*a1) + abs(snr) * abs(*a2);
00264 avb11 = abs(csl) * abs(*b1) + abs(snl) * abs(*b2);
00265
00266
00267
00268 if (abs(ua11) + abs(ua12) != 0.) {
00269 if (aua11 / (abs(ua11) + abs(ua12)) <= avb11 / (abs(vb11) +
00270 abs(vb12))) {
00271 dlartg_(&ua12, &ua11, csq, snq, &r__);
00272 } else {
00273 dlartg_(&vb12, &vb11, csq, snq, &r__);
00274 }
00275 } else {
00276 dlartg_(&vb12, &vb11, csq, snq, &r__);
00277 }
00278
00279 *csu = snr;
00280 *snu = csr;
00281 *csv = snl;
00282 *snv = csl;
00283
00284 }
00285
00286 }
00287
00288 return 0;
00289
00290
00291
00292 }