3 /* Subroutine */ int slartg_(real *f, real *g, real *cs, real *sn, real *r__)
5 /* System generated locals */
9 /* Builtin functions */
10 double log(doublereal), pow_ri(real *, integer *), sqrt(doublereal);
14 real f1, g1, eps, scale;
17 extern doublereal slamch_(char *);
21 /* -- LAPACK auxiliary routine (version 3.1) -- */
22 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
25 /* .. Scalar Arguments .. */
31 /* SLARTG generate a plane rotation so that */
33 /* [ CS SN ] . [ F ] = [ R ] where CS**2 + SN**2 = 1. */
34 /* [ -SN CS ] [ G ] [ 0 ] */
36 /* This is a slower, more accurate version of the BLAS1 routine SROTG, */
37 /* with the following other differences: */
38 /* F and G are unchanged on return. */
39 /* If G=0, then CS=1 and SN=0. */
40 /* If F=0 and (G .ne. 0), then CS=0 and SN=1 without doing any */
41 /* floating point operations (saves work in SBDSQR when */
42 /* there are zeros on the diagonal). */
44 /* If F exceeds G in magnitude, CS will be positive. */
50 /* The first component of vector to be rotated. */
53 /* The second component of vector to be rotated. */
55 /* CS (output) REAL */
56 /* The cosine of the rotation. */
58 /* SN (output) REAL */
59 /* The sine of the rotation. */
62 /* The nonzero component of the rotated vector. */
64 /* This version has a few statements commented out for thread safety */
65 /* (machine parameters are computed on each entry). 10 feb 03, SJH. */
67 /* ===================================================================== */
69 /* .. Parameters .. */
71 /* .. Local Scalars .. */
74 /* .. External Functions .. */
76 /* .. Intrinsic Functions .. */
78 /* .. Save statement .. */
79 /* SAVE FIRST, SAFMX2, SAFMIN, SAFMN2 */
81 /* .. Data statements .. */
82 /* DATA FIRST / .TRUE. / */
84 /* .. Executable Statements .. */
86 /* IF( FIRST ) THEN */
87 safmin = slamch_("S");
90 i__1 = (integer) (log(safmin / eps) / log(slamch_("B")) / 2.f);
91 safmn2 = pow_ri(&r__1, &i__1);
92 safmx2 = 1.f / safmn2;
99 } else if (*f == 0.f) {
107 r__1 = dabs(f1), r__2 = dabs(g1);
108 scale = dmax(r__1,r__2);
109 if (scale >= safmx2) {
116 r__1 = dabs(f1), r__2 = dabs(g1);
117 scale = dmax(r__1,r__2);
118 if (scale >= safmx2) {
121 /* Computing 2nd power */
123 /* Computing 2nd power */
125 *r__ = sqrt(r__1 * r__1 + r__2 * r__2);
129 for (i__ = 1; i__ <= i__1; ++i__) {
133 } else if (scale <= safmn2) {
140 r__1 = dabs(f1), r__2 = dabs(g1);
141 scale = dmax(r__1,r__2);
142 if (scale <= safmn2) {
145 /* Computing 2nd power */
147 /* Computing 2nd power */
149 *r__ = sqrt(r__1 * r__1 + r__2 * r__2);
153 for (i__ = 1; i__ <= i__1; ++i__) {
158 /* Computing 2nd power */
160 /* Computing 2nd power */
162 *r__ = sqrt(r__1 * r__1 + r__2 * r__2);
166 if (dabs(*f) > dabs(*g) && *cs < 0.f) {