3 /* Subroutine */ int slasd5_(integer *i__, real *d__, real *z__, real *delta,
4 real *rho, real *dsigma, real *work)
6 /* System generated locals */
9 /* Builtin functions */
10 double sqrt(doublereal);
13 real b, c__, w, del, tau, delsq;
16 /* -- LAPACK auxiliary routine (version 3.1) -- */
17 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
20 /* .. Scalar Arguments .. */
22 /* .. Array Arguments .. */
28 /* This subroutine computes the square root of the I-th eigenvalue */
29 /* of a positive symmetric rank-one modification of a 2-by-2 diagonal */
32 /* diag( D ) * diag( D ) + RHO * Z * transpose(Z) . */
34 /* The diagonal entries in the array D are assumed to satisfy */
36 /* 0 <= D(i) < D(j) for i < j . */
38 /* We also assume RHO > 0 and that the Euclidean norm of the vector */
44 /* I (input) INTEGER */
45 /* The index of the eigenvalue to be computed. I = 1 or I = 2. */
47 /* D (input) REAL array, dimension (2) */
48 /* The original eigenvalues. We assume 0 <= D(1) < D(2). */
50 /* Z (input) REAL array, dimension (2) */
51 /* The components of the updating vector. */
53 /* DELTA (output) REAL array, dimension (2) */
54 /* Contains (D(j) - sigma_I) in its j-th component. */
55 /* The vector DELTA contains the information necessary */
56 /* to construct the eigenvectors. */
58 /* RHO (input) REAL */
59 /* The scalar in the symmetric updating formula. */
61 /* DSIGMA (output) REAL */
62 /* The computed sigma_I, the I-th updated eigenvalue. */
64 /* WORK (workspace) REAL array, dimension (2) */
65 /* WORK contains (D(j) + sigma_I) in its j-th component. */
70 /* Based on contributions by */
71 /* Ren-Cang Li, Computer Science Division, University of California */
72 /* at Berkeley, USA */
74 /* ===================================================================== */
76 /* .. Parameters .. */
78 /* .. Local Scalars .. */
80 /* .. Intrinsic Functions .. */
82 /* .. Executable Statements .. */
84 /* Parameter adjustments */
91 del = d__[2] - d__[1];
92 delsq = del * (d__[2] + d__[1]);
94 w = *rho * 4.f * (z__[2] * z__[2] / (d__[1] + d__[2] * 3.f) - z__[1] *
95 z__[1] / (d__[1] * 3.f + d__[2])) / del + 1.f;
97 b = delsq + *rho * (z__[1] * z__[1] + z__[2] * z__[2]);
98 c__ = *rho * z__[1] * z__[1] * delsq;
100 /* B > ZERO, always */
102 /* The following TAU is DSIGMA * DSIGMA - D( 1 ) * D( 1 ) */
104 tau = c__ * 2.f / (b + sqrt((r__1 = b * b - c__ * 4.f, dabs(r__1))
107 /* The following TAU is DSIGMA - D( 1 ) */
109 tau /= d__[1] + sqrt(d__[1] * d__[1] + tau);
110 *dsigma = d__[1] + tau;
112 delta[2] = del - tau;
113 work[1] = d__[1] * 2.f + tau;
114 work[2] = d__[1] + tau + d__[2];
115 /* DELTA( 1 ) = -Z( 1 ) / TAU */
116 /* DELTA( 2 ) = Z( 2 ) / ( DEL-TAU ) */
118 b = -delsq + *rho * (z__[1] * z__[1] + z__[2] * z__[2]);
119 c__ = *rho * z__[2] * z__[2] * delsq;
121 /* The following TAU is DSIGMA * DSIGMA - D( 2 ) * D( 2 ) */
124 tau = c__ * -2.f / (b + sqrt(b * b + c__ * 4.f));
126 tau = (b - sqrt(b * b + c__ * 4.f)) / 2.f;
129 /* The following TAU is DSIGMA - D( 2 ) */
131 tau /= d__[2] + sqrt((r__1 = d__[2] * d__[2] + tau, dabs(r__1)));
132 *dsigma = d__[2] + tau;
133 delta[1] = -(del + tau);
135 work[1] = d__[1] + tau + d__[2];
136 work[2] = d__[2] * 2.f + tau;
137 /* DELTA( 1 ) = -Z( 1 ) / ( DEL+TAU ) */
138 /* DELTA( 2 ) = -Z( 2 ) / TAU */
140 /* TEMP = SQRT( DELTA( 1 )*DELTA( 1 )+DELTA( 2 )*DELTA( 2 ) ) */
141 /* DELTA( 1 ) = DELTA( 1 ) / TEMP */
142 /* DELTA( 2 ) = DELTA( 2 ) / TEMP */
147 b = -delsq + *rho * (z__[1] * z__[1] + z__[2] * z__[2]);
148 c__ = *rho * z__[2] * z__[2] * delsq;
150 /* The following TAU is DSIGMA * DSIGMA - D( 2 ) * D( 2 ) */
153 tau = (b + sqrt(b * b + c__ * 4.f)) / 2.f;
155 tau = c__ * 2.f / (-b + sqrt(b * b + c__ * 4.f));
158 /* The following TAU is DSIGMA - D( 2 ) */
160 tau /= d__[2] + sqrt(d__[2] * d__[2] + tau);
161 *dsigma = d__[2] + tau;
162 delta[1] = -(del + tau);
164 work[1] = d__[1] + tau + d__[2];
165 work[2] = d__[2] * 2.f + tau;
166 /* DELTA( 1 ) = -Z( 1 ) / ( DEL+TAU ) */
167 /* DELTA( 2 ) = -Z( 2 ) / TAU */
168 /* TEMP = SQRT( DELTA( 1 )*DELTA( 1 )+DELTA( 2 )*DELTA( 2 ) ) */
169 /* DELTA( 1 ) = DELTA( 1 ) / TEMP */
170 /* DELTA( 2 ) = DELTA( 2 ) / TEMP */