1 *> \brief \b DLARTGP generates a plane rotation so that the diagonal is nonnegative.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download DLARTGP + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlartgp.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlartgp.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlartgp.f">
21 * SUBROUTINE DLARTGP( F, G, CS, SN, R )
23 * .. Scalar Arguments ..
24 * DOUBLE PRECISION CS, F, G, R, SN
33 *> DLARTGP generates 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 Level 1 BLAS routine DROTG,
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.
44 *> The sign is chosen so that R >= 0.
52 *> F is DOUBLE PRECISION
53 *> The first component of vector to be rotated.
58 *> G is DOUBLE PRECISION
59 *> The second component of vector to be rotated.
64 *> CS is DOUBLE PRECISION
65 *> The cosine of the rotation.
70 *> SN is DOUBLE PRECISION
71 *> The sine of the rotation.
76 *> R is DOUBLE PRECISION
77 *> The nonzero component of the rotated vector.
79 *> This version has a few statements commented out for thread safety
80 *> (machine parameters are computed on each entry). 10 feb 03, SJH.
86 *> \author Univ. of Tennessee
87 *> \author Univ. of California Berkeley
88 *> \author Univ. of Colorado Denver
91 *> \date September 2012
93 *> \ingroup OTHERauxiliary
95 * =====================================================================
96 SUBROUTINE DLARTGP( F, G, CS, SN, R )
98 * -- LAPACK auxiliary routine (version 3.4.2) --
99 * -- LAPACK is a software package provided by Univ. of Tennessee, --
100 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
103 * .. Scalar Arguments ..
104 DOUBLE PRECISION CS, F, G, R, SN
107 * =====================================================================
110 DOUBLE PRECISION ZERO
111 PARAMETER ( ZERO = 0.0D0 )
113 PARAMETER ( ONE = 1.0D0 )
115 PARAMETER ( TWO = 2.0D0 )
117 * .. Local Scalars ..
120 DOUBLE PRECISION EPS, F1, G1, SAFMIN, SAFMN2, SAFMX2, SCALE
122 * .. External Functions ..
123 DOUBLE PRECISION DLAMCH
126 * .. Intrinsic Functions ..
127 INTRINSIC ABS, INT, LOG, MAX, SIGN, SQRT
129 * .. Save statement ..
130 * SAVE FIRST, SAFMX2, SAFMIN, SAFMN2
132 * .. Data statements ..
133 * DATA FIRST / .TRUE. /
135 * .. Executable Statements ..
138 SAFMIN = DLAMCH( 'S' )
140 SAFMN2 = DLAMCH( 'B' )**INT( LOG( SAFMIN / EPS ) /
141 $ LOG( DLAMCH( 'B' ) ) / TWO )
142 SAFMX2 = ONE / SAFMN2
149 ELSE IF( F.EQ.ZERO ) THEN
156 SCALE = MAX( ABS( F1 ), ABS( G1 ) )
157 IF( SCALE.GE.SAFMX2 ) THEN
163 SCALE = MAX( ABS( F1 ), ABS( G1 ) )
164 IF( SCALE.GE.SAFMX2 )
166 R = SQRT( F1**2+G1**2 )
172 ELSE IF( SCALE.LE.SAFMN2 ) THEN
178 SCALE = MAX( ABS( F1 ), ABS( G1 ) )
179 IF( SCALE.LE.SAFMN2 )
181 R = SQRT( F1**2+G1**2 )
188 R = SQRT( F1**2+G1**2 )