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

◆ slaed6()

subroutine slaed6 ( integer kniter,
logical orgati,
real rho,
real, dimension( 3 ) d,
real, dimension( 3 ) z,
real finit,
real tau,
integer info )

SLAED6 used by SSTEDC. Computes one Newton step in solution of the secular equation.

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

Purpose:
!>
!> SLAED6 computes the positive or negative root (closest to the origin)
!> of
!>                  z(1)        z(2)        z(3)
!> f(x) =   rho + --------- + ---------- + ---------
!>                 d(1)-x      d(2)-x      d(3)-x
!>
!> It is assumed that
!>
!>       if ORGATI = .true. the root is between d(2) and d(3);
!>       otherwise it is between d(1) and d(2)
!>
!> This routine will be called by SLAED4 when necessary. In most cases,
!> the root sought is the smallest in magnitude, though it might not be
!> in some extremely rare situations.
!> 
Parameters
[in]KNITER
!>          KNITER is INTEGER
!>               Refer to SLAED4 for its significance.
!> 
[in]ORGATI
!>          ORGATI is LOGICAL
!>               If ORGATI is true, the needed root is between d(2) and
!>               d(3); otherwise it is between d(1) and d(2).  See
!>               SLAED4 for further details.
!> 
[in]RHO
!>          RHO is REAL
!>               Refer to the equation f(x) above.
!> 
[in]D
!>          D is REAL array, dimension (3)
!>               D satisfies d(1) < d(2) < d(3).
!> 
[in]Z
!>          Z is REAL array, dimension (3)
!>               Each of the elements in z must be positive.
!> 
[in]FINIT
!>          FINIT is REAL
!>               The value of f at 0. It is more accurate than the one
!>               evaluated inside this routine (if someone wants to do
!>               so).
!> 
[out]TAU
!>          TAU is REAL
!>               The root of the equation f(x).
!> 
[out]INFO
!>          INFO is INTEGER
!>               = 0: successful exit
!>               > 0: if INFO = 1, failure to converge
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
!>
!>  10/02/03: This version has a few statements commented out for thread
!>  safety (machine parameters are computed on each entry). SJH.
!>
!>  05/10/06: Modified from a new version of Ren-Cang Li, use
!>     Gragg-Thornton-Warner cubic convergent scheme for better stability.
!> 
Contributors:
Ren-Cang Li, Computer Science Division, University of California at Berkeley, USA

Definition at line 137 of file slaed6.f.

139*
140* -- LAPACK computational routine --
141* -- LAPACK is a software package provided by Univ. of Tennessee, --
142* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
143*
144* .. Scalar Arguments ..
145 LOGICAL ORGATI
146 INTEGER INFO, KNITER
147 REAL FINIT, RHO, TAU
148* ..
149* .. Array Arguments ..
150 REAL D( 3 ), Z( 3 )
151* ..
152*
153* =====================================================================
154*
155* .. Parameters ..
156 INTEGER MAXIT
157 parameter( maxit = 40 )
158 REAL ZERO, ONE, TWO, THREE, FOUR, EIGHT
159 parameter( zero = 0.0e0, one = 1.0e0, two = 2.0e0,
160 $ three = 3.0e0, four = 4.0e0, eight = 8.0e0 )
161* ..
162* .. External Functions ..
163 REAL SLAMCH
164 EXTERNAL slamch
165* ..
166* .. Local Arrays ..
167 REAL DSCALE( 3 ), ZSCALE( 3 )
168* ..
169* .. Local Scalars ..
170 LOGICAL SCALE
171 INTEGER I, ITER, NITER
172 REAL A, B, BASE, C, DDF, DF, EPS, ERRETM, ETA, F,
173 $ FC, SCLFAC, SCLINV, SMALL1, SMALL2, SMINV1,
174 $ SMINV2, TEMP, TEMP1, TEMP2, TEMP3, TEMP4,
175 $ LBD, UBD
176* ..
177* .. Intrinsic Functions ..
178 INTRINSIC abs, int, log, max, min, sqrt
179* ..
180* .. Executable Statements ..
181*
182 info = 0
183*
184 IF( orgati ) THEN
185 lbd = d(2)
186 ubd = d(3)
187 ELSE
188 lbd = d(1)
189 ubd = d(2)
190 END IF
191 IF( finit .LT. zero )THEN
192 lbd = zero
193 ELSE
194 ubd = zero
195 END IF
196*
197 niter = 1
198 tau = zero
199 IF( kniter.EQ.2 ) THEN
200 IF( orgati ) THEN
201 temp = ( d( 3 )-d( 2 ) ) / two
202 c = rho + z( 1 ) / ( ( d( 1 )-d( 2 ) )-temp )
203 a = c*( d( 2 )+d( 3 ) ) + z( 2 ) + z( 3 )
204 b = c*d( 2 )*d( 3 ) + z( 2 )*d( 3 ) + z( 3 )*d( 2 )
205 ELSE
206 temp = ( d( 1 )-d( 2 ) ) / two
207 c = rho + z( 3 ) / ( ( d( 3 )-d( 2 ) )-temp )
208 a = c*( d( 1 )+d( 2 ) ) + z( 1 ) + z( 2 )
209 b = c*d( 1 )*d( 2 ) + z( 1 )*d( 2 ) + z( 2 )*d( 1 )
210 END IF
211 temp = max( abs( a ), abs( b ), abs( c ) )
212 a = a / temp
213 b = b / temp
214 c = c / temp
215 IF( c.EQ.zero ) THEN
216 tau = b / a
217 ELSE IF( a.LE.zero ) THEN
218 tau = ( a-sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
219 ELSE
220 tau = two*b / ( a+sqrt( abs( a*a-four*b*c ) ) )
221 END IF
222 IF( tau .LT. lbd .OR. tau .GT. ubd )
223 $ tau = ( lbd+ubd )/two
224 IF( d(1).EQ.tau .OR. d(2).EQ.tau .OR. d(3).EQ.tau ) THEN
225 tau = zero
226 ELSE
227 temp = finit + tau*z(1)/( d(1)*( d( 1 )-tau ) ) +
228 $ tau*z(2)/( d(2)*( d( 2 )-tau ) ) +
229 $ tau*z(3)/( d(3)*( d( 3 )-tau ) )
230 IF( temp .LE. zero )THEN
231 lbd = tau
232 ELSE
233 ubd = tau
234 END IF
235 IF( abs( finit ).LE.abs( temp ) )
236 $ tau = zero
237 END IF
238 END IF
239*
240* get machine parameters for possible scaling to avoid overflow
241*
242* modified by Sven: parameters SMALL1, SMINV1, SMALL2,
243* SMINV2, EPS are not SAVEd anymore between one call to the
244* others but recomputed at each call
245*
246 eps = slamch( 'Epsilon' )
247 base = slamch( 'Base' )
248 small1 = base**( int( log( slamch( 'SafMin' ) ) / log( base ) /
249 $ three ) )
250 sminv1 = one / small1
251 small2 = small1*small1
252 sminv2 = sminv1*sminv1
253*
254* Determine if scaling of inputs necessary to avoid overflow
255* when computing 1/TEMP**3
256*
257 IF( orgati ) THEN
258 temp = min( abs( d( 2 )-tau ), abs( d( 3 )-tau ) )
259 ELSE
260 temp = min( abs( d( 1 )-tau ), abs( d( 2 )-tau ) )
261 END IF
262 scale = .false.
263 IF( temp.LE.small1 ) THEN
264 scale = .true.
265 IF( temp.LE.small2 ) THEN
266*
267* Scale up by power of radix nearest 1/SAFMIN**(2/3)
268*
269 sclfac = sminv2
270 sclinv = small2
271 ELSE
272*
273* Scale up by power of radix nearest 1/SAFMIN**(1/3)
274*
275 sclfac = sminv1
276 sclinv = small1
277 END IF
278*
279* Scaling up safe because D, Z, TAU scaled elsewhere to be O(1)
280*
281 DO 10 i = 1, 3
282 dscale( i ) = d( i )*sclfac
283 zscale( i ) = z( i )*sclfac
284 10 CONTINUE
285 tau = tau*sclfac
286 lbd = lbd*sclfac
287 ubd = ubd*sclfac
288 ELSE
289*
290* Copy D and Z to DSCALE and ZSCALE
291*
292 DO 20 i = 1, 3
293 dscale( i ) = d( i )
294 zscale( i ) = z( i )
295 20 CONTINUE
296 END IF
297*
298 fc = zero
299 df = zero
300 ddf = zero
301 DO 30 i = 1, 3
302 temp = one / ( dscale( i )-tau )
303 temp1 = zscale( i )*temp
304 temp2 = temp1*temp
305 temp3 = temp2*temp
306 fc = fc + temp1 / dscale( i )
307 df = df + temp2
308 ddf = ddf + temp3
309 30 CONTINUE
310 f = finit + tau*fc
311*
312 IF( abs( f ).LE.zero )
313 $ GO TO 60
314 IF( f .LE. zero )THEN
315 lbd = tau
316 ELSE
317 ubd = tau
318 END IF
319*
320* Iteration begins -- Use Gragg-Thornton-Warner cubic convergent
321* scheme
322*
323* It is not hard to see that
324*
325* 1) Iterations will go up monotonically
326* if FINIT < 0;
327*
328* 2) Iterations will go down monotonically
329* if FINIT > 0.
330*
331 iter = niter + 1
332*
333 DO 50 niter = iter, maxit
334*
335 IF( orgati ) THEN
336 temp1 = dscale( 2 ) - tau
337 temp2 = dscale( 3 ) - tau
338 ELSE
339 temp1 = dscale( 1 ) - tau
340 temp2 = dscale( 2 ) - tau
341 END IF
342 a = ( temp1+temp2 )*f - temp1*temp2*df
343 b = temp1*temp2*f
344 c = f - ( temp1+temp2 )*df + temp1*temp2*ddf
345 temp = max( abs( a ), abs( b ), abs( c ) )
346 a = a / temp
347 b = b / temp
348 c = c / temp
349 IF( c.EQ.zero ) THEN
350 eta = b / a
351 ELSE IF( a.LE.zero ) THEN
352 eta = ( a-sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
353 ELSE
354 eta = two*b / ( a+sqrt( abs( a*a-four*b*c ) ) )
355 END IF
356 IF( f*eta.GE.zero ) THEN
357 eta = -f / df
358 END IF
359*
360 tau = tau + eta
361 IF( tau .LT. lbd .OR. tau .GT. ubd )
362 $ tau = ( lbd + ubd )/two
363*
364 fc = zero
365 erretm = zero
366 df = zero
367 ddf = zero
368 DO 40 i = 1, 3
369 IF ( ( dscale( i )-tau ).NE.zero ) THEN
370 temp = one / ( dscale( i )-tau )
371 temp1 = zscale( i )*temp
372 temp2 = temp1*temp
373 temp3 = temp2*temp
374 temp4 = temp1 / dscale( i )
375 fc = fc + temp4
376 erretm = erretm + abs( temp4 )
377 df = df + temp2
378 ddf = ddf + temp3
379 ELSE
380 GO TO 60
381 END IF
382 40 CONTINUE
383 f = finit + tau*fc
384 erretm = eight*( abs( finit )+abs( tau )*erretm ) +
385 $ abs( tau )*df
386 IF( ( abs( f ).LE.four*eps*erretm ) .OR.
387 $ ( (ubd-lbd).LE.four*eps*abs(tau) ) )
388 $ GO TO 60
389 IF( f .LE. zero )THEN
390 lbd = tau
391 ELSE
392 ubd = tau
393 END IF
394 50 CONTINUE
395 info = 1
396 60 CONTINUE
397*
398* Undo scaling
399*
400 IF( scale )
401 $ tau = tau*sclinv
402 RETURN
403*
404* End of SLAED6
405*
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
Here is the caller graph for this function: