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 integer c__1 = 1;
00019 static real c_b5 = 1.f;
00020
00021 int slaic1_(integer *job, integer *j, real *x, real *sest,
00022 real *w, real *gamma, real *sestpr, real *s, real *c__)
00023 {
00024
00025 real r__1, r__2, r__3, r__4;
00026
00027
00028 double sqrt(doublereal), r_sign(real *, real *);
00029
00030
00031 real b, t, s1, s2, eps, tmp, sine;
00032 extern doublereal sdot_(integer *, real *, integer *, real *, integer *);
00033 real test, zeta1, zeta2, alpha, norma, absgam, absalp;
00034 extern doublereal slamch_(char *);
00035 real cosine, absest;
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
00113
00114
00115
00116
00117
00118
00119
00120 --w;
00121 --x;
00122
00123
00124 eps = slamch_("Epsilon");
00125 alpha = sdot_(j, &x[1], &c__1, &w[1], &c__1);
00126
00127 absalp = dabs(alpha);
00128 absgam = dabs(*gamma);
00129 absest = dabs(*sest);
00130
00131 if (*job == 1) {
00132
00133
00134
00135
00136
00137 if (*sest == 0.f) {
00138 s1 = dmax(absgam,absalp);
00139 if (s1 == 0.f) {
00140 *s = 0.f;
00141 *c__ = 1.f;
00142 *sestpr = 0.f;
00143 } else {
00144 *s = alpha / s1;
00145 *c__ = *gamma / s1;
00146 tmp = sqrt(*s * *s + *c__ * *c__);
00147 *s /= tmp;
00148 *c__ /= tmp;
00149 *sestpr = s1 * tmp;
00150 }
00151 return 0;
00152 } else if (absgam <= eps * absest) {
00153 *s = 1.f;
00154 *c__ = 0.f;
00155 tmp = dmax(absest,absalp);
00156 s1 = absest / tmp;
00157 s2 = absalp / tmp;
00158 *sestpr = tmp * sqrt(s1 * s1 + s2 * s2);
00159 return 0;
00160 } else if (absalp <= eps * absest) {
00161 s1 = absgam;
00162 s2 = absest;
00163 if (s1 <= s2) {
00164 *s = 1.f;
00165 *c__ = 0.f;
00166 *sestpr = s2;
00167 } else {
00168 *s = 0.f;
00169 *c__ = 1.f;
00170 *sestpr = s1;
00171 }
00172 return 0;
00173 } else if (absest <= eps * absalp || absest <= eps * absgam) {
00174 s1 = absgam;
00175 s2 = absalp;
00176 if (s1 <= s2) {
00177 tmp = s1 / s2;
00178 *s = sqrt(tmp * tmp + 1.f);
00179 *sestpr = s2 * *s;
00180 *c__ = *gamma / s2 / *s;
00181 *s = r_sign(&c_b5, &alpha) / *s;
00182 } else {
00183 tmp = s2 / s1;
00184 *c__ = sqrt(tmp * tmp + 1.f);
00185 *sestpr = s1 * *c__;
00186 *s = alpha / s1 / *c__;
00187 *c__ = r_sign(&c_b5, gamma) / *c__;
00188 }
00189 return 0;
00190 } else {
00191
00192
00193
00194 zeta1 = alpha / absest;
00195 zeta2 = *gamma / absest;
00196
00197 b = (1.f - zeta1 * zeta1 - zeta2 * zeta2) * .5f;
00198 *c__ = zeta1 * zeta1;
00199 if (b > 0.f) {
00200 t = *c__ / (b + sqrt(b * b + *c__));
00201 } else {
00202 t = sqrt(b * b + *c__) - b;
00203 }
00204
00205 sine = -zeta1 / t;
00206 cosine = -zeta2 / (t + 1.f);
00207 tmp = sqrt(sine * sine + cosine * cosine);
00208 *s = sine / tmp;
00209 *c__ = cosine / tmp;
00210 *sestpr = sqrt(t + 1.f) * absest;
00211 return 0;
00212 }
00213
00214 } else if (*job == 2) {
00215
00216
00217
00218
00219
00220 if (*sest == 0.f) {
00221 *sestpr = 0.f;
00222 if (dmax(absgam,absalp) == 0.f) {
00223 sine = 1.f;
00224 cosine = 0.f;
00225 } else {
00226 sine = -(*gamma);
00227 cosine = alpha;
00228 }
00229
00230 r__1 = dabs(sine), r__2 = dabs(cosine);
00231 s1 = dmax(r__1,r__2);
00232 *s = sine / s1;
00233 *c__ = cosine / s1;
00234 tmp = sqrt(*s * *s + *c__ * *c__);
00235 *s /= tmp;
00236 *c__ /= tmp;
00237 return 0;
00238 } else if (absgam <= eps * absest) {
00239 *s = 0.f;
00240 *c__ = 1.f;
00241 *sestpr = absgam;
00242 return 0;
00243 } else if (absalp <= eps * absest) {
00244 s1 = absgam;
00245 s2 = absest;
00246 if (s1 <= s2) {
00247 *s = 0.f;
00248 *c__ = 1.f;
00249 *sestpr = s1;
00250 } else {
00251 *s = 1.f;
00252 *c__ = 0.f;
00253 *sestpr = s2;
00254 }
00255 return 0;
00256 } else if (absest <= eps * absalp || absest <= eps * absgam) {
00257 s1 = absgam;
00258 s2 = absalp;
00259 if (s1 <= s2) {
00260 tmp = s1 / s2;
00261 *c__ = sqrt(tmp * tmp + 1.f);
00262 *sestpr = absest * (tmp / *c__);
00263 *s = -(*gamma / s2) / *c__;
00264 *c__ = r_sign(&c_b5, &alpha) / *c__;
00265 } else {
00266 tmp = s2 / s1;
00267 *s = sqrt(tmp * tmp + 1.f);
00268 *sestpr = absest / *s;
00269 *c__ = alpha / s1 / *s;
00270 *s = -r_sign(&c_b5, gamma) / *s;
00271 }
00272 return 0;
00273 } else {
00274
00275
00276
00277 zeta1 = alpha / absest;
00278 zeta2 = *gamma / absest;
00279
00280
00281 r__3 = zeta1 * zeta1 + 1.f + (r__1 = zeta1 * zeta2, dabs(r__1)),
00282 r__4 = (r__2 = zeta1 * zeta2, dabs(r__2)) + zeta2 * zeta2;
00283 norma = dmax(r__3,r__4);
00284
00285
00286
00287 test = (zeta1 - zeta2) * 2.f * (zeta1 + zeta2) + 1.f;
00288 if (test >= 0.f) {
00289
00290
00291
00292 b = (zeta1 * zeta1 + zeta2 * zeta2 + 1.f) * .5f;
00293 *c__ = zeta2 * zeta2;
00294 t = *c__ / (b + sqrt((r__1 = b * b - *c__, dabs(r__1))));
00295 sine = zeta1 / (1.f - t);
00296 cosine = -zeta2 / t;
00297 *sestpr = sqrt(t + eps * 4.f * eps * norma) * absest;
00298 } else {
00299
00300
00301
00302 b = (zeta2 * zeta2 + zeta1 * zeta1 - 1.f) * .5f;
00303 *c__ = zeta1 * zeta1;
00304 if (b >= 0.f) {
00305 t = -(*c__) / (b + sqrt(b * b + *c__));
00306 } else {
00307 t = b - sqrt(b * b + *c__);
00308 }
00309 sine = -zeta1 / t;
00310 cosine = -zeta2 / (t + 1.f);
00311 *sestpr = sqrt(t + 1.f + eps * 4.f * eps * norma) * absest;
00312 }
00313 tmp = sqrt(sine * sine + cosine * cosine);
00314 *s = sine / tmp;
00315 *c__ = cosine / tmp;
00316 return 0;
00317
00318 }
00319 }
00320 return 0;
00321
00322
00323
00324 }