LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dlartgp.f
Go to the documentation of this file.
1*> \brief \b DLARTGP generates a plane rotation so that the diagonal is nonnegative.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DLARTGP + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlartgp.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlartgp.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlartgp.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DLARTGP( F, G, CS, SN, R )
20*
21* .. Scalar Arguments ..
22* DOUBLE PRECISION CS, F, G, R, SN
23* ..
24*
25*
26*> \par Purpose:
27* =============
28*>
29*> \verbatim
30*>
31*> DLARTGP generates a plane rotation so that
32*>
33*> [ CS SN ] . [ F ] = [ R ] where CS**2 + SN**2 = 1.
34*> [ -SN CS ] [ G ] [ 0 ]
35*>
36*> This is a slower, more accurate version of the Level 1 BLAS routine DROTG,
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.
41*>
42*> The sign is chosen so that R >= 0.
43*> \endverbatim
44*
45* Arguments:
46* ==========
47*
48*> \param[in] F
49*> \verbatim
50*> F is DOUBLE PRECISION
51*> The first component of vector to be rotated.
52*> \endverbatim
53*>
54*> \param[in] G
55*> \verbatim
56*> G is DOUBLE PRECISION
57*> The second component of vector to be rotated.
58*> \endverbatim
59*>
60*> \param[out] CS
61*> \verbatim
62*> CS is DOUBLE PRECISION
63*> The cosine of the rotation.
64*> \endverbatim
65*>
66*> \param[out] SN
67*> \verbatim
68*> SN is DOUBLE PRECISION
69*> The sine of the rotation.
70*> \endverbatim
71*>
72*> \param[out] R
73*> \verbatim
74*> R is DOUBLE PRECISION
75*> The nonzero component of the rotated vector.
76*>
77*> This version has a few statements commented out for thread safety
78*> (machine parameters are computed on each entry). 10 feb 03, SJH.
79*> \endverbatim
80*
81* Authors:
82* ========
83*
84*> \author Univ. of Tennessee
85*> \author Univ. of California Berkeley
86*> \author Univ. of Colorado Denver
87*> \author NAG Ltd.
88*
89*> \ingroup lartgp
90*
91* =====================================================================
92 SUBROUTINE dlartgp( F, G, CS, SN, R )
93*
94* -- LAPACK auxiliary routine --
95* -- LAPACK is a software package provided by Univ. of Tennessee, --
96* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
97*
98* .. Scalar Arguments ..
99 DOUBLE PRECISION CS, F, G, R, SN
100* ..
101*
102* =====================================================================
103*
104* .. Parameters ..
105 DOUBLE PRECISION ZERO
106 parameter( zero = 0.0d0 )
107 DOUBLE PRECISION ONE
108 parameter( one = 1.0d0 )
109 DOUBLE PRECISION TWO
110 parameter( two = 2.0d0 )
111* ..
112* .. Local Scalars ..
113* LOGICAL FIRST
114 INTEGER COUNT, I
115 DOUBLE PRECISION EPS, F1, G1, SAFMIN, SAFMN2, SAFMX2, SCALE
116* ..
117* .. External Functions ..
118 DOUBLE PRECISION DLAMCH
119 EXTERNAL dlamch
120* ..
121* .. Intrinsic Functions ..
122 INTRINSIC abs, int, log, max, sign, sqrt
123* ..
124* .. Save statement ..
125* SAVE FIRST, SAFMX2, SAFMIN, SAFMN2
126* ..
127* .. Data statements ..
128* DATA FIRST / .TRUE. /
129* ..
130* .. Executable Statements ..
131*
132* IF( FIRST ) THEN
133 safmin = dlamch( 'S' )
134 eps = dlamch( 'E' )
135 safmn2 = dlamch( 'B' )**int( log( safmin / eps ) /
136 $ log( dlamch( 'B' ) ) / two )
137 safmx2 = one / safmn2
138* FIRST = .FALSE.
139* END IF
140 IF( g.EQ.zero ) THEN
141 cs = sign( one, f )
142 sn = zero
143 r = abs( f )
144 ELSE IF( f.EQ.zero ) THEN
145 cs = zero
146 sn = sign( one, g )
147 r = abs( g )
148 ELSE
149 f1 = f
150 g1 = g
151 scale = max( abs( f1 ), abs( g1 ) )
152 IF( scale.GE.safmx2 ) THEN
153 count = 0
154 10 CONTINUE
155 count = count + 1
156 f1 = f1*safmn2
157 g1 = g1*safmn2
158 scale = max( abs( f1 ), abs( g1 ) )
159 IF( scale.GE.safmx2 .AND. count .LT. 20 )
160 $ GO TO 10
161 r = sqrt( f1**2+g1**2 )
162 cs = f1 / r
163 sn = g1 / r
164 DO 20 i = 1, count
165 r = r*safmx2
166 20 CONTINUE
167 ELSE IF( scale.LE.safmn2 ) THEN
168 count = 0
169 30 CONTINUE
170 count = count + 1
171 f1 = f1*safmx2
172 g1 = g1*safmx2
173 scale = max( abs( f1 ), abs( g1 ) )
174 IF( scale.LE.safmn2 )
175 $ GO TO 30
176 r = sqrt( f1**2+g1**2 )
177 cs = f1 / r
178 sn = g1 / r
179 DO 40 i = 1, count
180 r = r*safmn2
181 40 CONTINUE
182 ELSE
183 r = sqrt( f1**2+g1**2 )
184 cs = f1 / r
185 sn = g1 / r
186 END IF
187 IF( r.LT.zero ) THEN
188 cs = -cs
189 sn = -sn
190 r = -r
191 END IF
192 END IF
193 RETURN
194*
195* End of DLARTGP
196*
197 END
subroutine dlartgp(f, g, cs, sn, r)
DLARTGP generates a plane rotation so that the diagonal is nonnegative.
Definition dlartgp.f:93