3 /* Subroutine */ int dlasd5_(integer *i__, doublereal *d__, doublereal *z__,
4 doublereal *delta, doublereal *rho, doublereal *dsigma, doublereal *
7 /* System generated locals */
10 /* Builtin functions */
11 double sqrt(doublereal);
14 doublereal b, c__, w, del, tau, delsq;
17 /* -- LAPACK auxiliary routine (version 3.1) -- */
18 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
21 /* .. Scalar Arguments .. */
23 /* .. Array Arguments .. */
29 /* This subroutine computes the square root of the I-th eigenvalue */
30 /* of a positive symmetric rank-one modification of a 2-by-2 diagonal */
33 /* diag( D ) * diag( D ) + RHO * Z * transpose(Z) . */
35 /* The diagonal entries in the array D are assumed to satisfy */
37 /* 0 <= D(i) < D(j) for i < j . */
39 /* We also assume RHO > 0 and that the Euclidean norm of the vector */
45 /* I (input) INTEGER */
46 /* The index of the eigenvalue to be computed. I = 1 or I = 2. */
48 /* D (input) DOUBLE PRECISION array, dimension ( 2 ) */
49 /* The original eigenvalues. We assume 0 <= D(1) < D(2). */
51 /* Z (input) DOUBLE PRECISION array, dimension ( 2 ) */
52 /* The components of the updating vector. */
54 /* DELTA (output) DOUBLE PRECISION array, dimension ( 2 ) */
55 /* Contains (D(j) - sigma_I) in its j-th component. */
56 /* The vector DELTA contains the information necessary */
57 /* to construct the eigenvectors. */
59 /* RHO (input) DOUBLE PRECISION */
60 /* The scalar in the symmetric updating formula. */
62 /* DSIGMA (output) DOUBLE PRECISION */
63 /* The computed sigma_I, the I-th updated eigenvalue. */
65 /* WORK (workspace) DOUBLE PRECISION array, dimension ( 2 ) */
66 /* WORK contains (D(j) + sigma_I) in its j-th component. */
71 /* Based on contributions by */
72 /* Ren-Cang Li, Computer Science Division, University of California */
73 /* at Berkeley, USA */
75 /* ===================================================================== */
77 /* .. Parameters .. */
79 /* .. Local Scalars .. */
81 /* .. Intrinsic Functions .. */
83 /* .. Executable Statements .. */
85 /* Parameter adjustments */
92 del = d__[2] - d__[1];
93 delsq = del * (d__[2] + d__[1]);
95 w = *rho * 4. * (z__[2] * z__[2] / (d__[1] + d__[2] * 3.) - z__[1] *
96 z__[1] / (d__[1] * 3. + d__[2])) / del + 1.;
98 b = delsq + *rho * (z__[1] * z__[1] + z__[2] * z__[2]);
99 c__ = *rho * z__[1] * z__[1] * delsq;
101 /* B > ZERO, always */
103 /* The following TAU is DSIGMA * DSIGMA - D( 1 ) * D( 1 ) */
105 tau = c__ * 2. / (b + sqrt((d__1 = b * b - c__ * 4., abs(d__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. + 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. / (b + sqrt(b * b + c__ * 4.));
126 tau = (b - sqrt(b * b + c__ * 4.)) / 2.;
129 /* The following TAU is DSIGMA - D( 2 ) */
131 tau /= d__[2] + sqrt((d__1 = d__[2] * d__[2] + tau, abs(d__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. + 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.)) / 2.;
155 tau = c__ * 2. / (-b + sqrt(b * b + c__ * 4.));
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. + 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 */