00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int zlargv_(integer *n, doublecomplex *x, integer *incx,
00017 doublecomplex *y, integer *incy, doublereal *c__, integer *incc)
00018 {
00019
00020 integer i__1, i__2;
00021 doublereal d__1, d__2, d__3, d__4, d__5, d__6, d__7, d__8, d__9, d__10;
00022 doublecomplex z__1, z__2, z__3;
00023
00024
00025 double log(doublereal), pow_di(doublereal *, integer *), d_imag(
00026 doublecomplex *), sqrt(doublereal);
00027 void d_cnjg(doublecomplex *, doublecomplex *);
00028
00029
00030 doublereal d__;
00031 doublecomplex f, g;
00032 integer i__, j;
00033 doublecomplex r__;
00034 doublereal f2, g2;
00035 integer ic;
00036 doublereal di;
00037 doublecomplex ff;
00038 doublereal cs, dr;
00039 doublecomplex fs, gs;
00040 integer ix, iy;
00041 doublecomplex sn;
00042 doublereal f2s, g2s, eps, scale;
00043 integer count;
00044 doublereal safmn2;
00045 extern doublereal dlapy2_(doublereal *, doublereal *);
00046 doublereal safmx2;
00047 extern doublereal dlamch_(char *);
00048 doublereal safmin;
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 --c__;
00138 --y;
00139 --x;
00140
00141
00142 safmin = dlamch_("S");
00143 eps = dlamch_("E");
00144 d__1 = dlamch_("B");
00145 i__1 = (integer) (log(safmin / eps) / log(dlamch_("B")) / 2.);
00146 safmn2 = pow_di(&d__1, &i__1);
00147 safmx2 = 1. / safmn2;
00148
00149 ix = 1;
00150 iy = 1;
00151 ic = 1;
00152 i__1 = *n;
00153 for (i__ = 1; i__ <= i__1; ++i__) {
00154 i__2 = ix;
00155 f.r = x[i__2].r, f.i = x[i__2].i;
00156 i__2 = iy;
00157 g.r = y[i__2].r, g.i = y[i__2].i;
00158
00159
00160
00161
00162
00163 d__7 = (d__1 = f.r, abs(d__1)), d__8 = (d__2 = d_imag(&f), abs(d__2));
00164
00165 d__9 = (d__3 = g.r, abs(d__3)), d__10 = (d__4 = d_imag(&g), abs(d__4))
00166 ;
00167 d__5 = max(d__7,d__8), d__6 = max(d__9,d__10);
00168 scale = max(d__5,d__6);
00169 fs.r = f.r, fs.i = f.i;
00170 gs.r = g.r, gs.i = g.i;
00171 count = 0;
00172 if (scale >= safmx2) {
00173 L10:
00174 ++count;
00175 z__1.r = safmn2 * fs.r, z__1.i = safmn2 * fs.i;
00176 fs.r = z__1.r, fs.i = z__1.i;
00177 z__1.r = safmn2 * gs.r, z__1.i = safmn2 * gs.i;
00178 gs.r = z__1.r, gs.i = z__1.i;
00179 scale *= safmn2;
00180 if (scale >= safmx2) {
00181 goto L10;
00182 }
00183 } else if (scale <= safmn2) {
00184 if (g.r == 0. && g.i == 0.) {
00185 cs = 1.;
00186 sn.r = 0., sn.i = 0.;
00187 r__.r = f.r, r__.i = f.i;
00188 goto L50;
00189 }
00190 L20:
00191 --count;
00192 z__1.r = safmx2 * fs.r, z__1.i = safmx2 * fs.i;
00193 fs.r = z__1.r, fs.i = z__1.i;
00194 z__1.r = safmx2 * gs.r, z__1.i = safmx2 * gs.i;
00195 gs.r = z__1.r, gs.i = z__1.i;
00196 scale *= safmx2;
00197 if (scale <= safmn2) {
00198 goto L20;
00199 }
00200 }
00201
00202 d__1 = fs.r;
00203
00204 d__2 = d_imag(&fs);
00205 f2 = d__1 * d__1 + d__2 * d__2;
00206
00207 d__1 = gs.r;
00208
00209 d__2 = d_imag(&gs);
00210 g2 = d__1 * d__1 + d__2 * d__2;
00211 if (f2 <= max(g2,1.) * safmin) {
00212
00213
00214
00215 if (f.r == 0. && f.i == 0.) {
00216 cs = 0.;
00217 d__2 = g.r;
00218 d__3 = d_imag(&g);
00219 d__1 = dlapy2_(&d__2, &d__3);
00220 r__.r = d__1, r__.i = 0.;
00221
00222
00223 d__1 = gs.r;
00224 d__2 = d_imag(&gs);
00225 d__ = dlapy2_(&d__1, &d__2);
00226 d__1 = gs.r / d__;
00227 d__2 = -d_imag(&gs) / d__;
00228 z__1.r = d__1, z__1.i = d__2;
00229 sn.r = z__1.r, sn.i = z__1.i;
00230 goto L50;
00231 }
00232 d__1 = fs.r;
00233 d__2 = d_imag(&fs);
00234 f2s = dlapy2_(&d__1, &d__2);
00235
00236
00237 g2s = sqrt(g2);
00238
00239
00240
00241
00242
00243
00244
00245 cs = f2s / g2s;
00246
00247
00248
00249 d__3 = (d__1 = f.r, abs(d__1)), d__4 = (d__2 = d_imag(&f), abs(
00250 d__2));
00251 if (max(d__3,d__4) > 1.) {
00252 d__1 = f.r;
00253 d__2 = d_imag(&f);
00254 d__ = dlapy2_(&d__1, &d__2);
00255 d__1 = f.r / d__;
00256 d__2 = d_imag(&f) / d__;
00257 z__1.r = d__1, z__1.i = d__2;
00258 ff.r = z__1.r, ff.i = z__1.i;
00259 } else {
00260 dr = safmx2 * f.r;
00261 di = safmx2 * d_imag(&f);
00262 d__ = dlapy2_(&dr, &di);
00263 d__1 = dr / d__;
00264 d__2 = di / d__;
00265 z__1.r = d__1, z__1.i = d__2;
00266 ff.r = z__1.r, ff.i = z__1.i;
00267 }
00268 d__1 = gs.r / g2s;
00269 d__2 = -d_imag(&gs) / g2s;
00270 z__2.r = d__1, z__2.i = d__2;
00271 z__1.r = ff.r * z__2.r - ff.i * z__2.i, z__1.i = ff.r * z__2.i +
00272 ff.i * z__2.r;
00273 sn.r = z__1.r, sn.i = z__1.i;
00274 z__2.r = cs * f.r, z__2.i = cs * f.i;
00275 z__3.r = sn.r * g.r - sn.i * g.i, z__3.i = sn.r * g.i + sn.i *
00276 g.r;
00277 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00278 r__.r = z__1.r, r__.i = z__1.i;
00279 } else {
00280
00281
00282
00283
00284
00285 f2s = sqrt(g2 / f2 + 1.);
00286
00287
00288 d__1 = f2s * fs.r;
00289 d__2 = f2s * d_imag(&fs);
00290 z__1.r = d__1, z__1.i = d__2;
00291 r__.r = z__1.r, r__.i = z__1.i;
00292 cs = 1. / f2s;
00293 d__ = f2 + g2;
00294
00295 d__1 = r__.r / d__;
00296 d__2 = d_imag(&r__) / d__;
00297 z__1.r = d__1, z__1.i = d__2;
00298 sn.r = z__1.r, sn.i = z__1.i;
00299 d_cnjg(&z__2, &gs);
00300 z__1.r = sn.r * z__2.r - sn.i * z__2.i, z__1.i = sn.r * z__2.i +
00301 sn.i * z__2.r;
00302 sn.r = z__1.r, sn.i = z__1.i;
00303 if (count != 0) {
00304 if (count > 0) {
00305 i__2 = count;
00306 for (j = 1; j <= i__2; ++j) {
00307 z__1.r = safmx2 * r__.r, z__1.i = safmx2 * r__.i;
00308 r__.r = z__1.r, r__.i = z__1.i;
00309
00310 }
00311 } else {
00312 i__2 = -count;
00313 for (j = 1; j <= i__2; ++j) {
00314 z__1.r = safmn2 * r__.r, z__1.i = safmn2 * r__.i;
00315 r__.r = z__1.r, r__.i = z__1.i;
00316
00317 }
00318 }
00319 }
00320 }
00321 L50:
00322 c__[ic] = cs;
00323 i__2 = iy;
00324 y[i__2].r = sn.r, y[i__2].i = sn.i;
00325 i__2 = ix;
00326 x[i__2].r = r__.r, x[i__2].i = r__.i;
00327 ic += *incc;
00328 iy += *incy;
00329 ix += *incx;
00330
00331 }
00332 return 0;
00333
00334
00335
00336 }