Skip to content

Commit 4320882

Browse files
Starting to modify zlartg
1 parent ac11f62 commit 4320882

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

SRC/clartg.f90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ subroutine CLARTG( f, g, c, s, r )
224224
h2 = f2 + g2
225225
end if
226226
if( f2 > safmin * g2 ) then
227-
! Use a precise algorithm
228227
d = sqrt( w**2 + g2/f2 )
229228
c = w / d
230229
if( f2 > rtmin .and. h2 < rtmax ) then

SRC/zlartg.f90

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ subroutine ZLARTG( f, g, c, s, r )
129129
complex(wp) f, g, r, s
130130
! ..
131131
! .. Local Scalars ..
132-
real(wp) :: d, f1, f2, g1, g2, h2, p, u, uu, v, vv, w
132+
real(wp) :: d, f1, f2, g1, g2, h2, u, v, w
133133
complex(wp) :: fs, gs, t
134134
! ..
135135
! .. Intrinsic Functions ..
@@ -154,19 +154,16 @@ subroutine ZLARTG( f, g, c, s, r )
154154
!
155155
! Use unscaled algorithm
156156
!
157-
g2 = ABSSQ( g )
158-
d = sqrt( g2 )
157+
d = abs( g )
159158
s = conjg( g ) / d
160159
r = d
161160
else
162161
!
163162
! Use scaled algorithm
164163
!
165164
u = min( safmax, max( safmin, g1 ) )
166-
uu = one / u
167-
gs = g*uu
168-
g2 = ABSSQ( gs )
169-
d = sqrt( g2 )
165+
gs = g / u
166+
d = abs( gs )
170167
s = conjg( gs ) / d
171168
r = d*u
172169
end if
@@ -186,35 +183,32 @@ subroutine ZLARTG( f, g, c, s, r )
186183
else
187184
d = sqrt( f2 )*sqrt( h2 )
188185
end if
189-
p = 1 / d
190-
c = f2*p
191-
s = conjg( g )*( f*p )
192-
r = f*( h2*p )
186+
c = f2 / d
187+
s = conjg( g )*( f / d )
188+
r = f*( h2 / d )
193189
else
194190
!
195191
! Use scaled algorithm
196192
!
197193
u = min( safmax, max( safmin, f1, g1 ) )
198-
uu = one / u
199-
gs = g*uu
194+
gs = g / u
200195
g2 = ABSSQ( gs )
201-
if( f1*uu < rtmin ) then
196+
if( f1 < rtmin*u ) then
202197
!
203198
! f is not well-scaled when scaled by g1.
204199
! Use a different scaling for f.
205200
!
206201
v = min( safmax, max( safmin, f1 ) )
207-
vv = one / v
208-
w = v * uu
209-
fs = f*vv
202+
w = v / u
203+
fs = f / v
210204
f2 = ABSSQ( fs )
211205
h2 = f2*w**2 + g2
212206
else
213207
!
214208
! Otherwise use the same scaling for f and g.
215209
!
216210
w = one
217-
fs = f*uu
211+
fs = f / u
218212
f2 = ABSSQ( fs )
219213
h2 = f2 + g2
220214
end if
@@ -223,10 +217,9 @@ subroutine ZLARTG( f, g, c, s, r )
223217
else
224218
d = sqrt( f2 )*sqrt( h2 )
225219
end if
226-
p = 1 / d
227-
c = ( f2*p )*w
228-
s = conjg( gs )*( fs*p )
229-
r = ( fs*( h2*p ) )*u
220+
c = ( f2 / d )*w
221+
s = conjg( gs )*( fs / d )
222+
r = ( fs*( h2 / d ) )*u
230223
end if
231224
end if
232225
return

0 commit comments

Comments
 (0)