SUBROUTINE DLAZQ3( I0, N0, Z, PP, DMIN, SIGMA, DESIG, QMAX, NFAIL,
$ ITER, NDIV, IEEE, TTYPE, DMIN1, DMIN2, DN, DN1,
$ DN2, TAU )
LOGICAL IEEE
INTEGER I0, ITER, N0, NDIV, NFAIL, PP, TTYPE
DOUBLE PRECISION DESIG, DMIN, DMIN1, DMIN2, DN, DN1, DN2, QMAX,
$ SIGMA, TAU
DOUBLE PRECISION Z( * )
DOUBLE PRECISION CBIAS
PARAMETER ( CBIAS = 1.50D0 )
DOUBLE PRECISION ZERO, QURTR, HALF, ONE, TWO, HUNDRD
PARAMETER ( ZERO = 0.0D0, QURTR = 0.250D0, HALF = 0.5D0,
$ ONE = 1.0D0, TWO = 2.0D0, HUNDRD = 100.0D0 )
INTEGER IPN4, J4, N0IN, NN
DOUBLE PRECISION EPS, G, S, SAFMIN, T, TEMP, TOL, TOL2
EXTERNAL DLASQ5, DLASQ6, DLAZQ4
DOUBLE PRECISION DLAMCH
EXTERNAL DLAMCH
INTRINSIC ABS, MIN, SQRT
N0IN = N0
EPS = DLAMCH( 'Precision' )
SAFMIN = DLAMCH( 'Safe minimum' )
TOL = EPS*HUNDRD
TOL2 = TOL**2
G = ZERO
10 CONTINUE
IF( N0.LT.I0 )
$ RETURN
IF( N0.EQ.I0 )
$ GO TO 20
NN = 4*N0 + PP
IF( N0.EQ.( I0+1 ) )
$ GO TO 40
IF( Z( NN-5 ).GT.TOL2*( SIGMA+Z( NN-3 ) ) .AND.
$ Z( NN-2*PP-4 ).GT.TOL2*Z( NN-7 ) )
$ GO TO 30
20 CONTINUE
Z( 4*N0-3 ) = Z( 4*N0+PP-3 ) + SIGMA
N0 = N0 - 1
GO TO 10
30 CONTINUE
IF( Z( NN-9 ).GT.TOL2*SIGMA .AND.
$ Z( NN-2*PP-8 ).GT.TOL2*Z( NN-11 ) )
$ GO TO 50
40 CONTINUE
IF( Z( NN-3 ).GT.Z( NN-7 ) ) THEN
S = Z( NN-3 )
Z( NN-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 4*N0-PP ) = MIN( Z( 4*N0-PP ), Z( 4*I0-PP ),
$ Z( 4*I0-PP+4 ) )
QMAX = MAX( QMAX, Z( 4*I0+PP-3 ), Z( 4*I0+PP+1 ) )
DMIN = -ZERO
END IF
END IF
IF( DMIN.LT.ZERO .OR. SAFMIN*QMAX.LT.MIN( Z( 4*N0+PP-1 ),
$ Z( 4*N0+PP-9 ), DMIN2+Z( 4*N0-PP ) ) ) THEN
CALL DLAZQ4( I0, N0, Z, PP, N0IN, DMIN, DMIN1, DMIN2, DN, DN1,
$ DN2, TAU, TTYPE, G )
80 CONTINUE
CALL DLASQ5( I0, N0, Z, PP, TAU, DMIN, DMIN1, DMIN2, DN,
$ DN1, DN2, IEEE )
NDIV = NDIV + ( N0-I0+2 )
ITER = ITER + 1
IF( DMIN.GE.ZERO .AND. DMIN1.GT.ZERO ) THEN
GO TO 100
ELSE IF( DMIN.LT.ZERO .AND. DMIN1.GT.ZERO .AND.
$ Z( 4*( N0-1 )-PP ).LT.TOL*( SIGMA+DN1 ) .AND.
$ ABS( DN ).LT.TOL*SIGMA ) THEN
Z( 4*( N0-1 )-PP+2 ) = ZERO
DMIN = ZERO
GO TO 100
ELSE IF( DMIN.LT.ZERO ) THEN
NFAIL = NFAIL + 1
IF( TTYPE.LT.-22 ) THEN
TAU = ZERO
ELSE IF( DMIN1.GT.ZERO ) THEN
TAU = ( TAU+DMIN )*( ONE-TWO*EPS )
TTYPE = TTYPE - 11
ELSE
TAU = QURTR*TAU
TTYPE = TTYPE - 12
END IF
GO TO 80
ELSE IF( DMIN.NE.DMIN ) THEN
TAU = ZERO
GO TO 80
ELSE
GO TO 90
END IF
END IF
90 CONTINUE
CALL DLASQ6( I0, N0, Z, PP, DMIN, DMIN1, DMIN2, DN, DN1, DN2 )
NDIV = NDIV + ( N0-I0+2 )
ITER = ITER + 1
TAU = ZERO
100 CONTINUE
IF( TAU.LT.SIGMA ) THEN
DESIG = DESIG + TAU
T = SIGMA + DESIG
DESIG = DESIG - ( T-SIGMA )
ELSE
T = SIGMA + TAU
DESIG = SIGMA - ( T-TAU ) + DESIG
END IF
SIGMA = T
RETURN
END