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