3 /* Table of constant values */
5 static integer c__1 = 1;
6 static integer c__0 = 0;
7 static doublereal c_b8 = 1.;
9 /* Subroutine */ int dlasd8_(integer *icompq, integer *k, doublereal *d__,
10 doublereal *z__, doublereal *vf, doublereal *vl, doublereal *difl,
11 doublereal *difr, integer *lddifr, doublereal *dsigma, doublereal *
14 /* System generated locals */
15 integer difr_dim1, difr_offset, i__1, i__2;
16 doublereal d__1, d__2;
18 /* Builtin functions */
19 double sqrt(doublereal), d_sign(doublereal *, doublereal *);
24 integer iwk1, iwk2, iwk3;
25 extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *,
28 extern doublereal dnrm2_(integer *, doublereal *, integer *);
30 doublereal diflj, difrj, dsigj;
31 extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *,
32 doublereal *, integer *);
33 extern doublereal dlamc3_(doublereal *, doublereal *);
34 extern /* Subroutine */ int dlasd4_(integer *, integer *, doublereal *,
35 doublereal *, doublereal *, doublereal *, doublereal *,
36 doublereal *, integer *), dlascl_(char *, integer *, integer *,
37 doublereal *, doublereal *, integer *, integer *, doublereal *,
38 integer *, integer *), dlaset_(char *, integer *, integer
39 *, doublereal *, doublereal *, doublereal *, integer *),
40 xerbla_(char *, integer *);
44 /* -- LAPACK auxiliary routine (version 3.1) -- */
45 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
48 /* .. Scalar Arguments .. */
50 /* .. Array Arguments .. */
56 /* DLASD8 finds the square roots of the roots of the secular equation, */
57 /* as defined by the values in DSIGMA and Z. It makes the appropriate */
58 /* calls to DLASD4, and stores, for each element in D, the distance */
59 /* to its two nearest poles (elements in DSIGMA). It also updates */
60 /* the arrays VF and VL, the first and last components of all the */
61 /* right singular vectors of the original bidiagonal matrix. */
63 /* DLASD8 is called from DLASD6. */
68 /* ICOMPQ (input) INTEGER */
69 /* Specifies whether singular vectors are to be computed in */
70 /* factored form in the calling routine: */
71 /* = 0: Compute singular values only. */
72 /* = 1: Compute singular vectors in factored form as well. */
74 /* K (input) INTEGER */
75 /* The number of terms in the rational function to be solved */
76 /* by DLASD4. K >= 1. */
78 /* D (output) DOUBLE PRECISION array, dimension ( K ) */
79 /* On output, D contains the updated singular values. */
81 /* Z (input) DOUBLE PRECISION array, dimension ( K ) */
82 /* The first K elements of this array contain the components */
83 /* of the deflation-adjusted updating row vector. */
85 /* VF (input/output) DOUBLE PRECISION array, dimension ( K ) */
86 /* On entry, VF contains information passed through DBEDE8. */
87 /* On exit, VF contains the first K components of the first */
88 /* components of all right singular vectors of the bidiagonal */
91 /* VL (input/output) DOUBLE PRECISION array, dimension ( K ) */
92 /* On entry, VL contains information passed through DBEDE8. */
93 /* On exit, VL contains the first K components of the last */
94 /* components of all right singular vectors of the bidiagonal */
97 /* DIFL (output) DOUBLE PRECISION array, dimension ( K ) */
98 /* On exit, DIFL(I) = D(I) - DSIGMA(I). */
100 /* DIFR (output) DOUBLE PRECISION array, */
101 /* dimension ( LDDIFR, 2 ) if ICOMPQ = 1 and */
102 /* dimension ( K ) if ICOMPQ = 0. */
103 /* On exit, DIFR(I,1) = D(I) - DSIGMA(I+1), DIFR(K,1) is not */
104 /* defined and will not be referenced. */
106 /* If ICOMPQ = 1, DIFR(1:K,2) is an array containing the */
107 /* normalizing factors for the right singular vector matrix. */
109 /* LDDIFR (input) INTEGER */
110 /* The leading dimension of DIFR, must be at least K. */
112 /* DSIGMA (input) DOUBLE PRECISION array, dimension ( K ) */
113 /* The first K elements of this array contain the old roots */
114 /* of the deflated updating problem. These are the poles */
115 /* of the secular equation. */
117 /* WORK (workspace) DOUBLE PRECISION array, dimension at least 3 * K */
119 /* INFO (output) INTEGER */
120 /* = 0: successful exit. */
121 /* < 0: if INFO = -i, the i-th argument had an illegal value. */
122 /* > 0: if INFO = 1, an singular value did not converge */
124 /* Further Details */
125 /* =============== */
127 /* Based on contributions by */
128 /* Ming Gu and Huan Ren, Computer Science Division, University of */
129 /* California at Berkeley, USA */
131 /* ===================================================================== */
133 /* .. Parameters .. */
135 /* .. Local Scalars .. */
137 /* .. External Subroutines .. */
139 /* .. External Functions .. */
141 /* .. Intrinsic Functions .. */
143 /* .. Executable Statements .. */
145 /* Test the input parameters. */
147 /* Parameter adjustments */
154 difr_offset = 1 + difr_dim1;
162 if (*icompq < 0 || *icompq > 1) {
166 } else if (*lddifr < *k) {
171 xerbla_("DLASD8", &i__1);
175 /* Quick return if possible */
178 d__[1] = abs(z__[1]);
182 difr[(difr_dim1 << 1) + 1] = 1.;
187 /* Modify values DSIGMA(i) to make sure all DSIGMA(i)-DSIGMA(j) can */
188 /* be computed with high relative accuracy (barring over/underflow). */
189 /* This is a problem on machines without a guard digit in */
190 /* add/subtract (Cray XMP, Cray YMP, Cray C 90 and Cray 2). */
191 /* The following code replaces DSIGMA(I) by 2*DSIGMA(I)-DSIGMA(I), */
192 /* which on any of these machines zeros out the bottommost */
193 /* bit of DSIGMA(I) if it is 1; this makes the subsequent */
194 /* subtractions DSIGMA(I)-DSIGMA(J) unproblematic when cancellation */
195 /* occurs. On binary machines with a guard digit (almost all */
196 /* machines) it does not change DSIGMA(I) at all. On hexadecimal */
197 /* and decimal machines with a guard digit, it slightly */
198 /* changes the bottommost bits of DSIGMA(I). It does not account */
199 /* for hexadecimal or decimal machines without guard digits */
200 /* (we know of none). We use a subroutine call to compute */
201 /* 2*DSIGMA(I) to prevent optimizing compilers from eliminating */
205 for (i__ = 1; i__ <= i__1; ++i__) {
206 dsigma[i__] = dlamc3_(&dsigma[i__], &dsigma[i__]) - dsigma[i__];
220 rho = dnrm2_(k, &z__[1], &c__1);
221 dlascl_("G", &c__0, &c__0, &rho, &c_b8, k, &c__1, &z__[1], k, info);
224 /* Initialize WORK(IWK3). */
226 dlaset_("A", k, &c__1, &c_b8, &c_b8, &work[iwk3], k);
228 /* Compute the updated singular values, the arrays DIFL, DIFR, */
229 /* and the updated Z. */
232 for (j = 1; j <= i__1; ++j) {
233 dlasd4_(k, &j, &dsigma[1], &z__[1], &work[iwk1], &rho, &d__[j], &work[
236 /* If the root finder fails, the computation is terminated. */
241 work[iwk3i + j] = work[iwk3i + j] * work[j] * work[iwk2i + j];
243 difr[j + difr_dim1] = -work[j + 1];
245 for (i__ = 1; i__ <= i__2; ++i__) {
246 work[iwk3i + i__] = work[iwk3i + i__] * work[i__] * work[iwk2i +
247 i__] / (dsigma[i__] - dsigma[j]) / (dsigma[i__] + dsigma[
252 for (i__ = j + 1; i__ <= i__2; ++i__) {
253 work[iwk3i + i__] = work[iwk3i + i__] * work[i__] * work[iwk2i +
254 i__] / (dsigma[i__] - dsigma[j]) / (dsigma[i__] + dsigma[
261 /* Compute updated Z. */
264 for (i__ = 1; i__ <= i__1; ++i__) {
265 d__2 = sqrt((d__1 = work[iwk3i + i__], abs(d__1)));
266 z__[i__] = d_sign(&d__2, &z__[i__]);
270 /* Update VF and VL. */
273 for (j = 1; j <= i__1; ++j) {
278 difrj = -difr[j + difr_dim1];
279 dsigjp = -dsigma[j + 1];
281 work[j] = -z__[j] / diflj / (dsigma[j] + dj);
283 for (i__ = 1; i__ <= i__2; ++i__) {
284 work[i__] = z__[i__] / (dlamc3_(&dsigma[i__], &dsigj) - diflj) / (
289 for (i__ = j + 1; i__ <= i__2; ++i__) {
290 work[i__] = z__[i__] / (dlamc3_(&dsigma[i__], &dsigjp) + difrj) /
294 temp = dnrm2_(k, &work[1], &c__1);
295 work[iwk2i + j] = ddot_(k, &work[1], &c__1, &vf[1], &c__1) / temp;
296 work[iwk3i + j] = ddot_(k, &work[1], &c__1, &vl[1], &c__1) / temp;
298 difr[j + (difr_dim1 << 1)] = temp;
303 dcopy_(k, &work[iwk2], &c__1, &vf[1], &c__1);
304 dcopy_(k, &work[iwk3], &c__1, &vl[1], &c__1);