001:       SUBROUTINE SLAED5( I, D, Z, DELTA, RHO, DLAM )
002: *
003: *  -- LAPACK routine (version 3.2) --
004: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
005: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
006: *     November 2006
007: *
008: *     .. Scalar Arguments ..
009:       INTEGER            I
010:       REAL               DLAM, RHO
011: *     ..
012: *     .. Array Arguments ..
013:       REAL               D( 2 ), DELTA( 2 ), Z( 2 )
014: *     ..
015: *
016: *  Purpose
017: *  =======
018: *
019: *  This subroutine computes the I-th eigenvalue of a symmetric rank-one
020: *  modification of a 2-by-2 diagonal matrix
021: *
022: *             diag( D )  +  RHO *  Z * transpose(Z) .
023: *
024: *  The diagonal elements in the array D are assumed to satisfy
025: *
026: *             D(i) < D(j)  for  i < j .
027: *
028: *  We also assume RHO > 0 and that the Euclidean norm of the vector
029: *  Z is one.
030: *
031: *  Arguments
032: *  =========
033: *
034: *  I      (input) INTEGER
035: *         The index of the eigenvalue to be computed.  I = 1 or I = 2.
036: *
037: *  D      (input) REAL array, dimension (2)
038: *         The original eigenvalues.  We assume D(1) < D(2).
039: *
040: *  Z      (input) REAL array, dimension (2)
041: *         The components of the updating vector.
042: *
043: *  DELTA  (output) REAL array, dimension (2)
044: *         The vector DELTA contains the information necessary
045: *         to construct the eigenvectors.
046: *
047: *  RHO    (input) REAL
048: *         The scalar in the symmetric updating formula.
049: *
050: *  DLAM   (output) REAL
051: *         The computed lambda_I, the I-th updated eigenvalue.
052: *
053: *  Further Details
054: *  ===============
055: *
056: *  Based on contributions by
057: *     Ren-Cang Li, Computer Science Division, University of California
058: *     at Berkeley, USA
059: *
060: *  =====================================================================
061: *
062: *     .. Parameters ..
063:       REAL               ZERO, ONE, TWO, FOUR
064:       PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0, TWO = 2.0E0,
065:      $                   FOUR = 4.0E0 )
066: *     ..
067: *     .. Local Scalars ..
068:       REAL               B, C, DEL, TAU, TEMP, W
069: *     ..
070: *     .. Intrinsic Functions ..
071:       INTRINSIC          ABS, SQRT
072: *     ..
073: *     .. Executable Statements ..
074: *
075:       DEL = D( 2 ) - D( 1 )
076:       IF( I.EQ.1 ) THEN
077:          W = ONE + TWO*RHO*( Z( 2 )*Z( 2 )-Z( 1 )*Z( 1 ) ) / DEL
078:          IF( W.GT.ZERO ) THEN
079:             B = DEL + RHO*( Z( 1 )*Z( 1 )+Z( 2 )*Z( 2 ) )
080:             C = RHO*Z( 1 )*Z( 1 )*DEL
081: *
082: *           B > ZERO, always
083: *
084:             TAU = TWO*C / ( B+SQRT( ABS( B*B-FOUR*C ) ) )
085:             DLAM = D( 1 ) + TAU
086:             DELTA( 1 ) = -Z( 1 ) / TAU
087:             DELTA( 2 ) = Z( 2 ) / ( DEL-TAU )
088:          ELSE
089:             B = -DEL + RHO*( Z( 1 )*Z( 1 )+Z( 2 )*Z( 2 ) )
090:             C = RHO*Z( 2 )*Z( 2 )*DEL
091:             IF( B.GT.ZERO ) THEN
092:                TAU = -TWO*C / ( B+SQRT( B*B+FOUR*C ) )
093:             ELSE
094:                TAU = ( B-SQRT( B*B+FOUR*C ) ) / TWO
095:             END IF
096:             DLAM = D( 2 ) + TAU
097:             DELTA( 1 ) = -Z( 1 ) / ( DEL+TAU )
098:             DELTA( 2 ) = -Z( 2 ) / TAU
099:          END IF
100:          TEMP = SQRT( DELTA( 1 )*DELTA( 1 )+DELTA( 2 )*DELTA( 2 ) )
101:          DELTA( 1 ) = DELTA( 1 ) / TEMP
102:          DELTA( 2 ) = DELTA( 2 ) / TEMP
103:       ELSE
104: *
105: *     Now I=2
106: *
107:          B = -DEL + RHO*( Z( 1 )*Z( 1 )+Z( 2 )*Z( 2 ) )
108:          C = RHO*Z( 2 )*Z( 2 )*DEL
109:          IF( B.GT.ZERO ) THEN
110:             TAU = ( B+SQRT( B*B+FOUR*C ) ) / TWO
111:          ELSE
112:             TAU = TWO*C / ( -B+SQRT( B*B+FOUR*C ) )
113:          END IF
114:          DLAM = D( 2 ) + TAU
115:          DELTA( 1 ) = -Z( 1 ) / ( DEL+TAU )
116:          DELTA( 2 ) = -Z( 2 ) / TAU
117:          TEMP = SQRT( DELTA( 1 )*DELTA( 1 )+DELTA( 2 )*DELTA( 2 ) )
118:          DELTA( 1 ) = DELTA( 1 ) / TEMP
119:          DELTA( 2 ) = DELTA( 2 ) / TEMP
120:       END IF
121:       RETURN
122: *
123: *     End OF SLAED5
124: *
125:       END
126: