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 doublecomplex c_b1 = {1.,0.};
00019 static integer c__2 = 2;
00020
00021 int zlaesy_(doublecomplex *a, doublecomplex *b,
00022 doublecomplex *c__, doublecomplex *rt1, doublecomplex *rt2,
00023 doublecomplex *evscal, doublecomplex *cs1, doublecomplex *sn1)
00024 {
00025
00026 doublereal d__1, d__2;
00027 doublecomplex z__1, z__2, z__3, z__4, z__5, z__6, z__7;
00028
00029
00030 double z_abs(doublecomplex *);
00031 void pow_zi(doublecomplex *, doublecomplex *, integer *), z_sqrt(
00032 doublecomplex *, doublecomplex *), z_div(doublecomplex *,
00033 doublecomplex *, doublecomplex *);
00034
00035
00036 doublecomplex s, t;
00037 doublereal z__;
00038 doublecomplex tmp;
00039 doublereal babs, tabs, evnorm;
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 if (z_abs(b) == 0.) {
00111 rt1->r = a->r, rt1->i = a->i;
00112 rt2->r = c__->r, rt2->i = c__->i;
00113 if (z_abs(rt1) < z_abs(rt2)) {
00114 tmp.r = rt1->r, tmp.i = rt1->i;
00115 rt1->r = rt2->r, rt1->i = rt2->i;
00116 rt2->r = tmp.r, rt2->i = tmp.i;
00117 cs1->r = 0., cs1->i = 0.;
00118 sn1->r = 1., sn1->i = 0.;
00119 } else {
00120 cs1->r = 1., cs1->i = 0.;
00121 sn1->r = 0., sn1->i = 0.;
00122 }
00123 } else {
00124
00125
00126
00127
00128
00129
00130 z__2.r = a->r + c__->r, z__2.i = a->i + c__->i;
00131 z__1.r = z__2.r * .5, z__1.i = z__2.i * .5;
00132 s.r = z__1.r, s.i = z__1.i;
00133 z__2.r = a->r - c__->r, z__2.i = a->i - c__->i;
00134 z__1.r = z__2.r * .5, z__1.i = z__2.i * .5;
00135 t.r = z__1.r, t.i = z__1.i;
00136
00137
00138
00139 babs = z_abs(b);
00140 tabs = z_abs(&t);
00141 z__ = max(babs,tabs);
00142 if (z__ > 0.) {
00143 z__5.r = t.r / z__, z__5.i = t.i / z__;
00144 pow_zi(&z__4, &z__5, &c__2);
00145 z__7.r = b->r / z__, z__7.i = b->i / z__;
00146 pow_zi(&z__6, &z__7, &c__2);
00147 z__3.r = z__4.r + z__6.r, z__3.i = z__4.i + z__6.i;
00148 z_sqrt(&z__2, &z__3);
00149 z__1.r = z__ * z__2.r, z__1.i = z__ * z__2.i;
00150 t.r = z__1.r, t.i = z__1.i;
00151 }
00152
00153
00154
00155
00156 z__1.r = s.r + t.r, z__1.i = s.i + t.i;
00157 rt1->r = z__1.r, rt1->i = z__1.i;
00158 z__1.r = s.r - t.r, z__1.i = s.i - t.i;
00159 rt2->r = z__1.r, rt2->i = z__1.i;
00160 if (z_abs(rt1) < z_abs(rt2)) {
00161 tmp.r = rt1->r, tmp.i = rt1->i;
00162 rt1->r = rt2->r, rt1->i = rt2->i;
00163 rt2->r = tmp.r, rt2->i = tmp.i;
00164 }
00165
00166
00167
00168
00169
00170
00171 z__2.r = rt1->r - a->r, z__2.i = rt1->i - a->i;
00172 z_div(&z__1, &z__2, b);
00173 sn1->r = z__1.r, sn1->i = z__1.i;
00174 tabs = z_abs(sn1);
00175 if (tabs > 1.) {
00176
00177 d__2 = 1. / tabs;
00178 d__1 = d__2 * d__2;
00179 z__5.r = sn1->r / tabs, z__5.i = sn1->i / tabs;
00180 pow_zi(&z__4, &z__5, &c__2);
00181 z__3.r = d__1 + z__4.r, z__3.i = z__4.i;
00182 z_sqrt(&z__2, &z__3);
00183 z__1.r = tabs * z__2.r, z__1.i = tabs * z__2.i;
00184 t.r = z__1.r, t.i = z__1.i;
00185 } else {
00186 z__3.r = sn1->r * sn1->r - sn1->i * sn1->i, z__3.i = sn1->r *
00187 sn1->i + sn1->i * sn1->r;
00188 z__2.r = z__3.r + 1., z__2.i = z__3.i + 0.;
00189 z_sqrt(&z__1, &z__2);
00190 t.r = z__1.r, t.i = z__1.i;
00191 }
00192 evnorm = z_abs(&t);
00193 if (evnorm >= .1) {
00194 z_div(&z__1, &c_b1, &t);
00195 evscal->r = z__1.r, evscal->i = z__1.i;
00196 cs1->r = evscal->r, cs1->i = evscal->i;
00197 z__1.r = sn1->r * evscal->r - sn1->i * evscal->i, z__1.i = sn1->r
00198 * evscal->i + sn1->i * evscal->r;
00199 sn1->r = z__1.r, sn1->i = z__1.i;
00200 } else {
00201 evscal->r = 0., evscal->i = 0.;
00202 }
00203 }
00204 return 0;
00205
00206
00207
00208 }