1 *> \brief \b SLARTG generates a plane rotation with real cosine and real sine.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SLARTG + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slartg.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slartg.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slartg.f">
21 * SUBROUTINE SLARTG( F, G, CS, SN, R )
23 * .. Scalar Arguments ..
24 * REAL CS, F, G, R, SN
33 *> SLARTG generate a plane rotation so that
35 *> [ CS SN ] . [ F ] = [ R ] where CS**2 + SN**2 = 1.
36 *> [ -SN CS ] [ G ] [ 0 ]
38 *> This is a slower, more accurate version of the BLAS1 routine SROTG,
39 *> with the following other differences:
40 *> F and G are unchanged on return.
41 *> If G=0, then CS=1 and SN=0.
42 *> If F=0 and (G .ne. 0), then CS=0 and SN=1 without doing any
43 *> floating point operations (saves work in SBDSQR when
44 *> there are zeros on the diagonal).
46 *> If F exceeds G in magnitude, CS will be positive.
55 *> The first component of vector to be rotated.
61 *> The second component of vector to be rotated.
67 *> The cosine of the rotation.
73 *> The sine of the rotation.
79 *> The nonzero component of the rotated vector.
81 *> This version has a few statements commented out for thread safety
82 *> (machine parameters are computed on each entry). 10 feb 03, SJH.
88 *> \author Univ. of Tennessee
89 *> \author Univ. of California Berkeley
90 *> \author Univ. of Colorado Denver
93 *> \date September 2012
95 *> \ingroup OTHERauxiliary
97 * =====================================================================
98 SUBROUTINE SLARTG( F, G, CS, SN, R )
100 * -- LAPACK auxiliary routine (version 3.4.2) --
101 * -- LAPACK is a software package provided by Univ. of Tennessee, --
102 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
105 * .. Scalar Arguments ..
109 * =====================================================================
113 PARAMETER ( ZERO = 0.0E0 )
115 PARAMETER ( ONE = 1.0E0 )
117 PARAMETER ( TWO = 2.0E0 )
119 * .. Local Scalars ..
122 REAL EPS, F1, G1, SAFMIN, SAFMN2, SAFMX2, SCALE
124 * .. External Functions ..
128 * .. Intrinsic Functions ..
129 INTRINSIC ABS, INT, LOG, MAX, SQRT
131 * .. Save statement ..
132 * SAVE FIRST, SAFMX2, SAFMIN, SAFMN2
134 * .. Data statements ..
135 * DATA FIRST / .TRUE. /
137 * .. Executable Statements ..
140 SAFMIN = SLAMCH( 'S' )
142 SAFMN2 = SLAMCH( 'B' )**INT( LOG( SAFMIN / EPS ) /
143 $ LOG( SLAMCH( 'B' ) ) / TWO )
144 SAFMX2 = ONE / SAFMN2
151 ELSE IF( F.EQ.ZERO ) THEN
158 SCALE = MAX( ABS( F1 ), ABS( G1 ) )
159 IF( SCALE.GE.SAFMX2 ) THEN
165 SCALE = MAX( ABS( F1 ), ABS( G1 ) )
166 IF( SCALE.GE.SAFMX2 )
168 R = SQRT( F1**2+G1**2 )
174 ELSE IF( SCALE.LE.SAFMN2 ) THEN
180 SCALE = MAX( ABS( F1 ), ABS( G1 ) )
181 IF( SCALE.LE.SAFMN2 )
183 R = SQRT( F1**2+G1**2 )
190 R = SQRT( F1**2+G1**2 )
194 IF( ABS( F ).GT.ABS( G ) .AND. CS.LT.ZERO ) THEN