1 *> \brief \b SLASQ3 checks for deflation, computes a shift and calls dqds. Used by sbdsqr.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SLASQ3 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slasq3.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slasq3.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slasq3.f">
21 * SUBROUTINE SLASQ3( I0, N0, Z, PP, DMIN, SIGMA, DESIG, QMAX, NFAIL,
22 * ITER, NDIV, IEEE, TTYPE, DMIN1, DMIN2, DN, DN1,
25 * .. Scalar Arguments ..
27 * INTEGER I0, ITER, N0, NDIV, NFAIL, PP
28 * REAL DESIG, DMIN, DMIN1, DMIN2, DN, DN1, DN2, G,
31 * .. Array Arguments ..
41 *> SLASQ3 checks for deflation, computes a shift (TAU) and calls dqds.
42 *> In case of failure it changes shifts, and tries again until output
63 *> Z is REAL array, dimension ( 4*N0 )
64 *> Z holds the qd array.
70 *> PP=0 for ping, PP=1 for pong.
71 *> PP=2 indicates that flipping was applied to the Z array
72 *> and that the initial tests for deflation should not be
79 *> Minimum value of d.
85 *> Sum of shifts used in current segment.
88 *> \param[in,out] DESIG
91 *> Lower order part of SIGMA
97 *> Maximum value of q.
100 *> \param[in,out] NFAIL
103 *> Increment NFAIL by 1 each time the shift was too big.
106 *> \param[in,out] ITER
109 *> Increment ITER by 1 for each iteration.
112 *> \param[in,out] NDIV
115 *> Increment NDIV by 1 for each division.
121 *> Flag for IEEE or non IEEE arithmetic (passed to SLASQ5).
124 *> \param[in,out] TTYPE
130 *> \param[in,out] DMIN1
135 *> \param[in,out] DMIN2
145 *> \param[in,out] DN1
150 *> \param[in,out] DN2
160 *> \param[in,out] TAU
164 *> These are passed as arguments in order to save their values
165 *> between calls to SLASQ3.
171 *> \author Univ. of Tennessee
172 *> \author Univ. of California Berkeley
173 *> \author Univ. of Colorado Denver
178 *> \ingroup auxOTHERcomputational
180 * =====================================================================
181 SUBROUTINE SLASQ3( I0, N0, Z, PP, DMIN, SIGMA, DESIG, QMAX, NFAIL,
182 $ ITER, NDIV, IEEE, TTYPE, DMIN1, DMIN2, DN, DN1,
185 * -- LAPACK computational routine (version 3.6.1) --
186 * -- LAPACK is a software package provided by Univ. of Tennessee, --
187 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
190 * .. Scalar Arguments ..
192 INTEGER I0, ITER, N0, NDIV, NFAIL, PP
193 REAL DESIG, DMIN, DMIN1, DMIN2, DN, DN1, DN2, G,
196 * .. Array Arguments ..
200 * =====================================================================
204 PARAMETER ( CBIAS = 1.50E0 )
205 REAL ZERO, QURTR, HALF, ONE, TWO, HUNDRD
206 PARAMETER ( ZERO = 0.0E0, QURTR = 0.250E0, HALF = 0.5E0,
207 $ ONE = 1.0E0, TWO = 2.0E0, HUNDRD = 100.0E0 )
209 * .. Local Scalars ..
210 INTEGER IPN4, J4, N0IN, NN, TTYPE
211 REAL EPS, S, T, TEMP, TOL, TOL2
213 * .. External Subroutines ..
214 EXTERNAL SLASQ4, SLASQ5, SLASQ6
216 * .. External Function ..
219 EXTERNAL SISNAN, SLAMCH
221 * .. Intrinsic Functions ..
222 INTRINSIC ABS, MAX, MIN, SQRT
224 * .. Executable Statements ..
227 EPS = SLAMCH( 'Precision' )
231 * Check for deflation.
243 * Check whether E(N0-1) is negligible, 1 eigenvalue.
245 IF( Z( NN-5 ).GT.TOL2*( SIGMA+Z( NN-3 ) ) .AND.
246 $ Z( NN-2*PP-4 ).GT.TOL2*Z( NN-7 ) )
251 Z( 4*N0-3 ) = Z( 4*N0+PP-3 ) + SIGMA
255 * Check whether E(N0-2) is negligible, 2 eigenvalues.
259 IF( Z( NN-9 ).GT.TOL2*SIGMA .AND.
260 $ Z( NN-2*PP-8 ).GT.TOL2*Z( NN-11 ) )
265 IF( Z( NN-3 ).GT.Z( NN-7 ) ) THEN
267 Z( NN-3 ) = Z( NN-7 )
270 T = HALF*( ( Z( NN-7 )-Z( NN-3 ) )+Z( NN-5 ) )
271 IF( Z( NN-5 ).GT.Z( NN-3 )*TOL2.AND.T.NE.ZERO ) THEN
272 S = Z( NN-3 )*( Z( NN-5 ) / T )
274 S = Z( NN-3 )*( Z( NN-5 ) /
275 $ ( T*( ONE+SQRT( ONE+S / T ) ) ) )
277 S = Z( NN-3 )*( Z( NN-5 ) / ( T+SQRT( T )*SQRT( T+S ) ) )
279 T = Z( NN-7 ) + ( S+Z( NN-5 ) )
280 Z( NN-3 ) = Z( NN-3 )*( Z( NN-7 ) / T )
283 Z( 4*N0-7 ) = Z( NN-7 ) + SIGMA
284 Z( 4*N0-3 ) = Z( NN-3 ) + SIGMA
292 * Reverse the qd-array, if warranted.
294 IF( DMIN.LE.ZERO .OR. N0.LT.N0IN ) THEN
295 IF( CBIAS*Z( 4*I0+PP-3 ).LT.Z( 4*N0+PP-3 ) ) THEN
297 DO 60 J4 = 4*I0, 2*( I0+N0-1 ), 4
299 Z( J4-3 ) = Z( IPN4-J4-3 )
300 Z( IPN4-J4-3 ) = TEMP
302 Z( J4-2 ) = Z( IPN4-J4-2 )
303 Z( IPN4-J4-2 ) = TEMP
305 Z( J4-1 ) = Z( IPN4-J4-5 )
306 Z( IPN4-J4-5 ) = TEMP
308 Z( J4 ) = Z( IPN4-J4-4 )
309 Z( IPN4-J4-4 ) = TEMP
311 IF( N0-I0.LE.4 ) THEN
312 Z( 4*N0+PP-1 ) = Z( 4*I0+PP-1 )
313 Z( 4*N0-PP ) = Z( 4*I0-PP )
315 DMIN2 = MIN( DMIN2, Z( 4*N0+PP-1 ) )
316 Z( 4*N0+PP-1 ) = MIN( Z( 4*N0+PP-1 ), Z( 4*I0+PP-1 ),
318 Z( 4*N0-PP ) = MIN( Z( 4*N0-PP ), Z( 4*I0-PP ),
320 QMAX = MAX( QMAX, Z( 4*I0+PP-3 ), Z( 4*I0+PP+1 ) )
327 CALL SLASQ4( I0, N0, Z, PP, N0IN, DMIN, DMIN1, DMIN2, DN, DN1,
328 $ DN2, TAU, TTYPE, G )
330 * Call dqds until DMIN > 0.
334 CALL SLASQ5( I0, N0, Z, PP, TAU, SIGMA, DMIN, DMIN1, DMIN2, DN,
335 $ DN1, DN2, IEEE, EPS )
337 NDIV = NDIV + ( N0-I0+2 )
342 IF( DMIN.GE.ZERO .AND. DMIN1.GE.ZERO ) THEN
348 ELSE IF( DMIN.LT.ZERO .AND. DMIN1.GT.ZERO .AND.
349 $ Z( 4*( N0-1 )-PP ).LT.TOL*( SIGMA+DN1 ) .AND.
350 $ ABS( DN ).LT.TOL*SIGMA ) THEN
352 * Convergence hidden by negative DN.
354 Z( 4*( N0-1 )-PP+2 ) = ZERO
357 ELSE IF( DMIN.LT.ZERO ) THEN
359 * TAU too big. Select new TAU and try again.
362 IF( TTYPE.LT.-22 ) THEN
364 * Failed twice. Play it safe.
367 ELSE IF( DMIN1.GT.ZERO ) THEN
369 * Late failure. Gives excellent shift.
371 TAU = ( TAU+DMIN )*( ONE-TWO*EPS )
375 * Early failure. Divide by 4.
381 ELSE IF( SISNAN( DMIN ) ) THEN
385 IF( TAU.EQ.ZERO ) THEN
393 * Possible underflow. Play it safe.
401 CALL SLASQ6( I0, N0, Z, PP, DMIN, DMIN1, DMIN2, DN, DN1, DN2 )
402 NDIV = NDIV + ( N0-I0+2 )
407 IF( TAU.LT.SIGMA ) THEN
410 DESIG = DESIG - ( T-SIGMA )
413 DESIG = SIGMA - ( T-TAU ) + DESIG