LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ slartgp()

subroutine slartgp ( real f,
real g,
real cs,
real sn,
real r )

SLARTGP generates a plane rotation so that the diagonal is nonnegative.

Download SLARTGP + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> SLARTGP generates a plane rotation so that
!>
!>    [  CS  SN  ]  .  [ F ]  =  [ R ]   where CS**2 + SN**2 = 1.
!>    [ -SN  CS  ]     [ G ]     [ 0 ]
!>
!> This is a slower, more accurate version of the Level 1 BLAS routine SROTG,
!> with the following other differences:
!>    F and G are unchanged on return.
!>    If G=0, then CS=(+/-)1 and SN=0.
!>    If F=0 and (G .ne. 0), then CS=0 and SN=(+/-)1.
!>
!> The sign is chosen so that R >= 0.
!> 
Parameters
[in]F
!>          F is REAL
!>          The first component of vector to be rotated.
!> 
[in]G
!>          G is REAL
!>          The second component of vector to be rotated.
!> 
[out]CS
!>          CS is REAL
!>          The cosine of the rotation.
!> 
[out]SN
!>          SN is REAL
!>          The sine of the rotation.
!> 
[out]R
!>          R is REAL
!>          The nonzero component of the rotated vector.
!>
!>  This version has a few statements commented out for thread safety
!>  (machine parameters are computed on each entry). 10 feb 03, SJH.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 92 of file slartgp.f.

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 REAL CS, F, G, R, SN
100* ..
101*
102* =====================================================================
103*
104* .. Parameters ..
105 REAL ZERO
106 parameter( zero = 0.0e0 )
107 REAL ONE
108 parameter( one = 1.0e0 )
109 REAL TWO
110 parameter( two = 2.0e0 )
111* ..
112* .. Local Scalars ..
113* LOGICAL FIRST
114 INTEGER COUNT, I
115 REAL EPS, F1, G1, SAFMIN, SAFMN2, SAFMX2, SCALE
116* ..
117* .. External Functions ..
118 REAL SLAMCH
119 EXTERNAL slamch
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 = slamch( 'S' )
134 eps = slamch( 'E' )
135 safmn2 = slamch( 'B' )**int( log( safmin / eps ) /
136 $ log( slamch( '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 SLARTGP
196*
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
Here is the caller graph for this function: