1 /* ../netlib/dlasda.f -- translated by f2c (version 20100827). You must link the resulting object file with libf2c: on Microsoft Windows system, link with libf2c.lib;
2 on Linux or Unix systems, link with .../path/to/libf2c.a -lm or, if you install libf2c.a in a standard place, with -lf2c -lm -- in that order, at the end of the command line, as in cc *.o -lf2c -lm Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., http://www.netlib.org/f2c/libf2c.zip */
3 #include "FLA_f2c.h" /* Table of constant values */
4 static integer c__0 = 0;
5 static doublereal c_b11 = 0.;
6 static doublereal c_b12 = 1.;
7 static integer c__1 = 1;
8 static integer c__2 = 2;
9 /* > \brief \b DLASDA computes the singular value decomposition (SVD) of a real upper bidiagonal matrix with d iagonal d and off-diagonal e. Used by sbdsdc. */
10 /* =========== DOCUMENTATION =========== */
11 /* Online html documentation available at */
12 /* http://www.netlib.org/lapack/explore-html/ */
13 /* > \htmlonly */
14 /* > Download DLASDA + dependencies */
15 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlasda. f"> */
16 /* > [TGZ]</a> */
17 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlasda. f"> */
18 /* > [ZIP]</a> */
19 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlasda. f"> */
20 /* > [TXT]</a> */
21 /* > \endhtmlonly */
22 /* Definition: */
23 /* =========== */
24 /* SUBROUTINE DLASDA( ICOMPQ, SMLSIZ, N, SQRE, D, E, U, LDU, VT, K, */
25 /* DIFL, DIFR, Z, POLES, GIVPTR, GIVCOL, LDGCOL, */
26 /* PERM, GIVNUM, C, S, WORK, IWORK, INFO ) */
27 /* .. Scalar Arguments .. */
28 /* INTEGER ICOMPQ, INFO, LDGCOL, LDU, N, SMLSIZ, SQRE */
29 /* .. */
30 /* .. Array Arguments .. */
31 /* INTEGER GIVCOL( LDGCOL, * ), GIVPTR( * ), IWORK( * ), */
32 /* $ K( * ), PERM( LDGCOL, * ) */
33 /* DOUBLE PRECISION C( * ), D( * ), DIFL( LDU, * ), DIFR( LDU, * ), */
34 /* $ E( * ), GIVNUM( LDU, * ), POLES( LDU, * ), */
35 /* $ S( * ), U( LDU, * ), VT( LDU, * ), WORK( * ), */
36 /* $ Z( LDU, * ) */
37 /* .. */
38 /* > \par Purpose: */
39 /* ============= */
40 /* > */
41 /* > \verbatim */
42 /* > */
43 /* > Using a divide and conquer approach, DLASDA computes the singular */
44 /* > value decomposition (SVD) of a real upper bidiagonal N-by-M matrix */
45 /* > B with diagonal D and offdiagonal E, where M = N + SQRE. The */
46 /* > algorithm computes the singular values in the SVD B = U * S * VT. */
47 /* > The orthogonal matrices U and VT are optionally computed in */
48 /* > compact form. */
49 /* > */
50 /* > A related subroutine, DLASD0, computes the singular values and */
51 /* > the singular vectors in explicit form. */
52 /* > \endverbatim */
53 /* Arguments: */
54 /* ========== */
55 /* > \param[in] ICOMPQ */
56 /* > \verbatim */
57 /* > ICOMPQ is INTEGER */
58 /* > Specifies whether singular vectors are to be computed */
59 /* > in compact form, as follows */
60 /* > = 0: Compute singular values only. */
61 /* > = 1: Compute singular vectors of upper bidiagonal */
62 /* > matrix in compact form. */
63 /* > \endverbatim */
64 /* > */
65 /* > \param[in] SMLSIZ */
66 /* > \verbatim */
67 /* > SMLSIZ is INTEGER */
68 /* > The maximum size of the subproblems at the bottom of the */
69 /* > computation tree. */
70 /* > \endverbatim */
71 /* > */
72 /* > \param[in] N */
73 /* > \verbatim */
74 /* > N is INTEGER */
75 /* > The row dimension of the upper bidiagonal matrix. This is */
76 /* > also the dimension of the main diagonal array D. */
77 /* > \endverbatim */
78 /* > */
79 /* > \param[in] SQRE */
80 /* > \verbatim */
81 /* > SQRE is INTEGER */
82 /* > Specifies the column dimension of the bidiagonal matrix. */
83 /* > = 0: The bidiagonal matrix has column dimension M = N;
84 */
85 /* > = 1: The bidiagonal matrix has column dimension M = N + 1. */
86 /* > \endverbatim */
87 /* > */
88 /* > \param[in,out] D */
89 /* > \verbatim */
90 /* > D is DOUBLE PRECISION array, dimension ( N ) */
91 /* > On entry D contains the main diagonal of the bidiagonal */
92 /* > matrix. On exit D, if INFO = 0, contains its singular values. */
93 /* > \endverbatim */
94 /* > */
95 /* > \param[in] E */
96 /* > \verbatim */
97 /* > E is DOUBLE PRECISION array, dimension ( M-1 ) */
98 /* > Contains the subdiagonal entries of the bidiagonal matrix. */
99 /* > On exit, E has been destroyed. */
100 /* > \endverbatim */
101 /* > */
102 /* > \param[out] U */
103 /* > \verbatim */
104 /* > U is DOUBLE PRECISION array, */
105 /* > dimension ( LDU, SMLSIZ ) if ICOMPQ = 1, and not referenced */
106 /* > if ICOMPQ = 0. If ICOMPQ = 1, on exit, U contains the left */
107 /* > singular vector matrices of all subproblems at the bottom */
108 /* > level. */
109 /* > \endverbatim */
110 /* > */
111 /* > \param[in] LDU */
112 /* > \verbatim */
113 /* > LDU is INTEGER, LDU = > N. */
114 /* > The leading dimension of arrays U, VT, DIFL, DIFR, POLES, */
115 /* > GIVNUM, and Z. */
116 /* > \endverbatim */
117 /* > */
118 /* > \param[out] VT */
119 /* > \verbatim */
120 /* > VT is DOUBLE PRECISION array, */
121 /* > dimension ( LDU, SMLSIZ+1 ) if ICOMPQ = 1, and not referenced */
122 /* > if ICOMPQ = 0. If ICOMPQ = 1, on exit, VT**T contains the right */
123 /* > singular vector matrices of all subproblems at the bottom */
124 /* > level. */
125 /* > \endverbatim */
126 /* > */
127 /* > \param[out] K */
128 /* > \verbatim */
129 /* > K is INTEGER array, */
130 /* > dimension ( N ) if ICOMPQ = 1 and dimension 1 if ICOMPQ = 0. */
131 /* > If ICOMPQ = 1, on exit, K(I) is the dimension of the I-th */
132 /* > secular equation on the computation tree. */
133 /* > \endverbatim */
134 /* > */
135 /* > \param[out] DIFL */
136 /* > \verbatim */
137 /* > DIFL is DOUBLE PRECISION array, dimension ( LDU, NLVL ), */
138 /* > where NLVL = floor(log_2 (N/SMLSIZ))). */
139 /* > \endverbatim */
140 /* > */
141 /* > \param[out] DIFR */
142 /* > \verbatim */
143 /* > DIFR is DOUBLE PRECISION array, */
144 /* > dimension ( LDU, 2 * NLVL ) if ICOMPQ = 1 and */
145 /* > dimension ( N ) if ICOMPQ = 0. */
146 /* > If ICOMPQ = 1, on exit, DIFL(1:N, I) and DIFR(1:N, 2 * I - 1) */
147 /* > record distances between singular values on the I-th */
148 /* > level and singular values on the (I -1)-th level, and */
149 /* > DIFR(1:N, 2 * I ) contains the normalizing factors for */
150 /* > the right singular vector matrix. See DLASD8 for details. */
151 /* > \endverbatim */
152 /* > */
153 /* > \param[out] Z */
154 /* > \verbatim */
155 /* > Z is DOUBLE PRECISION array, */
156 /* > dimension ( LDU, NLVL ) if ICOMPQ = 1 and */
157 /* > dimension ( N ) if ICOMPQ = 0. */
158 /* > The first K elements of Z(1, I) contain the components of */
159 /* > the deflation-adjusted updating row vector for subproblems */
160 /* > on the I-th level. */
161 /* > \endverbatim */
162 /* > */
163 /* > \param[out] POLES */
164 /* > \verbatim */
165 /* > POLES is DOUBLE PRECISION array, */
166 /* > dimension ( LDU, 2 * NLVL ) if ICOMPQ = 1, and not referenced */
167 /* > if ICOMPQ = 0. If ICOMPQ = 1, on exit, POLES(1, 2*I - 1) and */
168 /* > POLES(1, 2*I) contain the new and old singular values */
169 /* > involved in the secular equations on the I-th level. */
170 /* > \endverbatim */
171 /* > */
172 /* > \param[out] GIVPTR */
173 /* > \verbatim */
174 /* > GIVPTR is INTEGER array, */
175 /* > dimension ( N ) if ICOMPQ = 1, and not referenced if */
176 /* > ICOMPQ = 0. If ICOMPQ = 1, on exit, GIVPTR( I ) records */
177 /* > the number of Givens rotations performed on the I-th */
178 /* > problem on the computation tree. */
179 /* > \endverbatim */
180 /* > */
181 /* > \param[out] GIVCOL */
182 /* > \verbatim */
183 /* > GIVCOL is INTEGER array, */
184 /* > dimension ( LDGCOL, 2 * NLVL ) if ICOMPQ = 1, and not */
185 /* > referenced if ICOMPQ = 0. If ICOMPQ = 1, on exit, for each I, */
186 /* > GIVCOL(1, 2 *I - 1) and GIVCOL(1, 2 *I) record the locations */
187 /* > of Givens rotations performed on the I-th level on the */
188 /* > computation tree. */
189 /* > \endverbatim */
190 /* > */
191 /* > \param[in] LDGCOL */
192 /* > \verbatim */
193 /* > LDGCOL is INTEGER, LDGCOL = > N. */
194 /* > The leading dimension of arrays GIVCOL and PERM. */
195 /* > \endverbatim */
196 /* > */
197 /* > \param[out] PERM */
198 /* > \verbatim */
199 /* > PERM is INTEGER array, */
200 /* > dimension ( LDGCOL, NLVL ) if ICOMPQ = 1, and not referenced */
201 /* > if ICOMPQ = 0. If ICOMPQ = 1, on exit, PERM(1, I) records */
202 /* > permutations done on the I-th level of the computation tree. */
203 /* > \endverbatim */
204 /* > */
205 /* > \param[out] GIVNUM */
206 /* > \verbatim */
207 /* > GIVNUM is DOUBLE PRECISION array, */
208 /* > dimension ( LDU, 2 * NLVL ) if ICOMPQ = 1, and not */
209 /* > referenced if ICOMPQ = 0. If ICOMPQ = 1, on exit, for each I, */
210 /* > GIVNUM(1, 2 *I - 1) and GIVNUM(1, 2 *I) record the C- and S- */
211 /* > values of Givens rotations performed on the I-th level on */
212 /* > the computation tree. */
213 /* > \endverbatim */
214 /* > */
215 /* > \param[out] C */
216 /* > \verbatim */
217 /* > C is DOUBLE PRECISION array, */
218 /* > dimension ( N ) if ICOMPQ = 1, and dimension 1 if ICOMPQ = 0. */
219 /* > If ICOMPQ = 1 and the I-th subproblem is not square, on exit, */
220 /* > C( I ) contains the C-value of a Givens rotation related to */
221 /* > the right null space of the I-th subproblem. */
222 /* > \endverbatim */
223 /* > */
224 /* > \param[out] S */
225 /* > \verbatim */
226 /* > S is DOUBLE PRECISION array, dimension ( N ) if */
227 /* > ICOMPQ = 1, and dimension 1 if ICOMPQ = 0. If ICOMPQ = 1 */
228 /* > and the I-th subproblem is not square, on exit, S( I ) */
229 /* > contains the S-value of a Givens rotation related to */
230 /* > the right null space of the I-th subproblem. */
231 /* > \endverbatim */
232 /* > */
233 /* > \param[out] WORK */
234 /* > \verbatim */
235 /* > WORK is DOUBLE PRECISION array, dimension */
236 /* > (6 * N + (SMLSIZ + 1)*(SMLSIZ + 1)). */
237 /* > \endverbatim */
238 /* > */
239 /* > \param[out] IWORK */
240 /* > \verbatim */
241 /* > IWORK is INTEGER array. */
242 /* > Dimension must be at least (7 * N). */
243 /* > \endverbatim */
244 /* > */
245 /* > \param[out] INFO */
246 /* > \verbatim */
247 /* > INFO is INTEGER */
248 /* > = 0: successful exit. */
249 /* > < 0: if INFO = -i, the i-th argument had an illegal value. */
250 /* > > 0: if INFO = 1, a singular value did not converge */
251 /* > \endverbatim */
252 /* Authors: */
253 /* ======== */
254 /* > \author Univ. of Tennessee */
255 /* > \author Univ. of California Berkeley */
256 /* > \author Univ. of Colorado Denver */
257 /* > \author NAG Ltd. */
258 /* > \date September 2012 */
259 /* > \ingroup auxOTHERauxiliary */
260 /* > \par Contributors: */
261 /* ================== */
262 /* > */
263 /* > Ming Gu and Huan Ren, Computer Science Division, University of */
264 /* > California at Berkeley, USA */
265 /* > */
266 /* ===================================================================== */
267 /* Subroutine */
dlasda_(integer * icompq,integer * smlsiz,integer * n,integer * sqre,doublereal * d__,doublereal * e,doublereal * u,integer * ldu,doublereal * vt,integer * k,doublereal * difl,doublereal * difr,doublereal * z__,doublereal * poles,integer * givptr,integer * givcol,integer * ldgcol,integer * perm,doublereal * givnum,doublereal * c__,doublereal * s,doublereal * work,integer * iwork,integer * info)268 int dlasda_(integer *icompq, integer *smlsiz, integer *n, integer *sqre, doublereal *d__, doublereal *e, doublereal *u, integer *ldu, doublereal *vt, integer *k, doublereal *difl, doublereal *difr, doublereal *z__, doublereal *poles, integer *givptr, integer *givcol, integer *ldgcol, integer *perm, doublereal *givnum, doublereal *c__, doublereal *s, doublereal *work, integer *iwork, integer *info)
269 {
270 /* System generated locals */
271 integer givcol_dim1, givcol_offset, perm_dim1, perm_offset, difl_dim1, difl_offset, difr_dim1, difr_offset, givnum_dim1, givnum_offset, poles_dim1, poles_offset, u_dim1, u_offset, vt_dim1, vt_offset, z_dim1, z_offset, i__1, i__2;
272 /* Builtin functions */
273 integer pow_ii(integer *, integer *);
274 /* Local variables */
275 integer i__, j, m, i1, ic, lf, nd, ll, nl, vf, nr, vl, im1, ncc, nlf, nrf, vfi, iwk, vli, lvl, nru, ndb1, nlp1, lvl2, nrp1;
276 doublereal beta;
277 integer idxq, nlvl;
278 doublereal alpha;
279 integer inode, ndiml, ndimr, idxqi, itemp;
280 extern /* Subroutine */
281 int dcopy_(integer *, doublereal *, integer *, doublereal *, integer *);
282 integer sqrei;
283 extern /* Subroutine */
284 int dlasd6_(integer *, integer *, integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, integer *, integer *, integer *, integer *, doublereal *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, doublereal *, doublereal *, integer *, integer *);
285 integer nwork1, nwork2;
286 extern /* Subroutine */
287 int dlasdq_(char *, integer *, integer *, integer *, integer *, integer *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, integer *, doublereal *, integer *, doublereal *, integer *), dlasdt_(integer *, integer *, integer *, integer *, integer *, integer *, integer *), dlaset_( char *, integer *, integer *, doublereal *, doublereal *, doublereal *, integer *), xerbla_(char *, integer *);
288 integer smlszp;
289 /* -- LAPACK auxiliary routine (version 3.4.2) -- */
290 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
291 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
292 /* September 2012 */
293 /* .. Scalar Arguments .. */
294 /* .. */
295 /* .. Array Arguments .. */
296 /* .. */
297 /* ===================================================================== */
298 /* .. Parameters .. */
299 /* .. */
300 /* .. Local Scalars .. */
301 /* .. */
302 /* .. External Subroutines .. */
303 /* .. */
304 /* .. Executable Statements .. */
305 /* Test the input parameters. */
306 /* Parameter adjustments */
307 --d__;
308 --e;
309 givnum_dim1 = *ldu;
310 givnum_offset = 1 + givnum_dim1;
311 givnum -= givnum_offset;
312 poles_dim1 = *ldu;
313 poles_offset = 1 + poles_dim1;
314 poles -= poles_offset;
315 z_dim1 = *ldu;
316 z_offset = 1 + z_dim1;
317 z__ -= z_offset;
318 difr_dim1 = *ldu;
319 difr_offset = 1 + difr_dim1;
320 difr -= difr_offset;
321 difl_dim1 = *ldu;
322 difl_offset = 1 + difl_dim1;
323 difl -= difl_offset;
324 vt_dim1 = *ldu;
325 vt_offset = 1 + vt_dim1;
326 vt -= vt_offset;
327 u_dim1 = *ldu;
328 u_offset = 1 + u_dim1;
329 u -= u_offset;
330 --k;
331 --givptr;
332 perm_dim1 = *ldgcol;
333 perm_offset = 1 + perm_dim1;
334 perm -= perm_offset;
335 givcol_dim1 = *ldgcol;
336 givcol_offset = 1 + givcol_dim1;
337 givcol -= givcol_offset;
338 --c__;
339 --s;
340 --work;
341 --iwork;
342 /* Function Body */
343 *info = 0;
344 if (*icompq < 0 || *icompq > 1)
345 {
346 *info = -1;
347 }
348 else if (*smlsiz < 3)
349 {
350 *info = -2;
351 }
352 else if (*n < 0)
353 {
354 *info = -3;
355 }
356 else if (*sqre < 0 || *sqre > 1)
357 {
358 *info = -4;
359 }
360 else if (*ldu < *n + *sqre)
361 {
362 *info = -8;
363 }
364 else if (*ldgcol < *n)
365 {
366 *info = -17;
367 }
368 if (*info != 0)
369 {
370 i__1 = -(*info);
371 xerbla_("DLASDA", &i__1);
372 return 0;
373 }
374 m = *n + *sqre;
375 /* If the input matrix is too small, call DLASDQ to find the SVD. */
376 if (*n <= *smlsiz)
377 {
378 if (*icompq == 0)
379 {
380 dlasdq_("U", sqre, n, &c__0, &c__0, &c__0, &d__[1], &e[1], &vt[ vt_offset], ldu, &u[u_offset], ldu, &u[u_offset], ldu, & work[1], info);
381 }
382 else
383 {
384 dlasdq_("U", sqre, n, &m, n, &c__0, &d__[1], &e[1], &vt[vt_offset] , ldu, &u[u_offset], ldu, &u[u_offset], ldu, &work[1], info);
385 }
386 return 0;
387 }
388 /* Book-keeping and set up the computation tree. */
389 inode = 1;
390 ndiml = inode + *n;
391 ndimr = ndiml + *n;
392 idxq = ndimr + *n;
393 iwk = idxq + *n;
394 ncc = 0;
395 nru = 0;
396 smlszp = *smlsiz + 1;
397 vf = 1;
398 vl = vf + m;
399 nwork1 = vl + m;
400 nwork2 = nwork1 + smlszp * smlszp;
401 dlasdt_(n, &nlvl, &nd, &iwork[inode], &iwork[ndiml], &iwork[ndimr], smlsiz);
402 /* for the nodes on bottom level of the tree, solve */
403 /* their subproblems by DLASDQ. */
404 ndb1 = (nd + 1) / 2;
405 i__1 = nd;
406 for (i__ = ndb1;
407 i__ <= i__1;
408 ++i__)
409 {
410 /* IC : center row of each node */
411 /* NL : number of rows of left subproblem */
412 /* NR : number of rows of right subproblem */
413 /* NLF: starting row of the left subproblem */
414 /* NRF: starting row of the right subproblem */
415 i1 = i__ - 1;
416 ic = iwork[inode + i1];
417 nl = iwork[ndiml + i1];
418 nlp1 = nl + 1;
419 nr = iwork[ndimr + i1];
420 nlf = ic - nl;
421 nrf = ic + 1;
422 idxqi = idxq + nlf - 2;
423 vfi = vf + nlf - 1;
424 vli = vl + nlf - 1;
425 sqrei = 1;
426 if (*icompq == 0)
427 {
428 dlaset_("A", &nlp1, &nlp1, &c_b11, &c_b12, &work[nwork1], &smlszp);
429 dlasdq_("U", &sqrei, &nl, &nlp1, &nru, &ncc, &d__[nlf], &e[nlf], & work[nwork1], &smlszp, &work[nwork2], &nl, &work[nwork2], &nl, &work[nwork2], info);
430 itemp = nwork1 + nl * smlszp;
431 dcopy_(&nlp1, &work[nwork1], &c__1, &work[vfi], &c__1);
432 dcopy_(&nlp1, &work[itemp], &c__1, &work[vli], &c__1);
433 }
434 else
435 {
436 dlaset_("A", &nl, &nl, &c_b11, &c_b12, &u[nlf + u_dim1], ldu);
437 dlaset_("A", &nlp1, &nlp1, &c_b11, &c_b12, &vt[nlf + vt_dim1], ldu);
438 dlasdq_("U", &sqrei, &nl, &nlp1, &nl, &ncc, &d__[nlf], &e[nlf], & vt[nlf + vt_dim1], ldu, &u[nlf + u_dim1], ldu, &u[nlf + u_dim1], ldu, &work[nwork1], info);
439 dcopy_(&nlp1, &vt[nlf + vt_dim1], &c__1, &work[vfi], &c__1);
440 dcopy_(&nlp1, &vt[nlf + nlp1 * vt_dim1], &c__1, &work[vli], &c__1) ;
441 }
442 if (*info != 0)
443 {
444 return 0;
445 }
446 i__2 = nl;
447 for (j = 1;
448 j <= i__2;
449 ++j)
450 {
451 iwork[idxqi + j] = j;
452 /* L10: */
453 }
454 if (i__ == nd && *sqre == 0)
455 {
456 sqrei = 0;
457 }
458 else
459 {
460 sqrei = 1;
461 }
462 idxqi += nlp1;
463 vfi += nlp1;
464 vli += nlp1;
465 nrp1 = nr + sqrei;
466 if (*icompq == 0)
467 {
468 dlaset_("A", &nrp1, &nrp1, &c_b11, &c_b12, &work[nwork1], &smlszp);
469 dlasdq_("U", &sqrei, &nr, &nrp1, &nru, &ncc, &d__[nrf], &e[nrf], & work[nwork1], &smlszp, &work[nwork2], &nr, &work[nwork2], &nr, &work[nwork2], info);
470 itemp = nwork1 + (nrp1 - 1) * smlszp;
471 dcopy_(&nrp1, &work[nwork1], &c__1, &work[vfi], &c__1);
472 dcopy_(&nrp1, &work[itemp], &c__1, &work[vli], &c__1);
473 }
474 else
475 {
476 dlaset_("A", &nr, &nr, &c_b11, &c_b12, &u[nrf + u_dim1], ldu);
477 dlaset_("A", &nrp1, &nrp1, &c_b11, &c_b12, &vt[nrf + vt_dim1], ldu);
478 dlasdq_("U", &sqrei, &nr, &nrp1, &nr, &ncc, &d__[nrf], &e[nrf], & vt[nrf + vt_dim1], ldu, &u[nrf + u_dim1], ldu, &u[nrf + u_dim1], ldu, &work[nwork1], info);
479 dcopy_(&nrp1, &vt[nrf + vt_dim1], &c__1, &work[vfi], &c__1);
480 dcopy_(&nrp1, &vt[nrf + nrp1 * vt_dim1], &c__1, &work[vli], &c__1) ;
481 }
482 if (*info != 0)
483 {
484 return 0;
485 }
486 i__2 = nr;
487 for (j = 1;
488 j <= i__2;
489 ++j)
490 {
491 iwork[idxqi + j] = j;
492 /* L20: */
493 }
494 /* L30: */
495 }
496 /* Now conquer each subproblem bottom-up. */
497 j = pow_ii(&c__2, &nlvl);
498 for (lvl = nlvl;
499 lvl >= 1;
500 --lvl)
501 {
502 lvl2 = (lvl << 1) - 1;
503 /* Find the first node LF and last node LL on */
504 /* the current level LVL. */
505 if (lvl == 1)
506 {
507 lf = 1;
508 ll = 1;
509 }
510 else
511 {
512 i__1 = lvl - 1;
513 lf = pow_ii(&c__2, &i__1);
514 ll = (lf << 1) - 1;
515 }
516 i__1 = ll;
517 for (i__ = lf;
518 i__ <= i__1;
519 ++i__)
520 {
521 im1 = i__ - 1;
522 ic = iwork[inode + im1];
523 nl = iwork[ndiml + im1];
524 nr = iwork[ndimr + im1];
525 nlf = ic - nl;
526 nrf = ic + 1;
527 if (i__ == ll)
528 {
529 sqrei = *sqre;
530 }
531 else
532 {
533 sqrei = 1;
534 }
535 vfi = vf + nlf - 1;
536 vli = vl + nlf - 1;
537 idxqi = idxq + nlf - 1;
538 alpha = d__[ic];
539 beta = e[ic];
540 if (*icompq == 0)
541 {
542 dlasd6_(icompq, &nl, &nr, &sqrei, &d__[nlf], &work[vfi], & work[vli], &alpha, &beta, &iwork[idxqi], &perm[ perm_offset], &givptr[1], &givcol[givcol_offset], ldgcol, &givnum[givnum_offset], ldu, &poles[ poles_offset], &difl[difl_offset], &difr[difr_offset], &z__[z_offset], &k[1], &c__[1], &s[1], &work[nwork1], &iwork[iwk], info);
543 }
544 else
545 {
546 --j;
547 dlasd6_(icompq, &nl, &nr, &sqrei, &d__[nlf], &work[vfi], & work[vli], &alpha, &beta, &iwork[idxqi], &perm[nlf + lvl * perm_dim1], &givptr[j], &givcol[nlf + lvl2 * givcol_dim1], ldgcol, &givnum[nlf + lvl2 * givnum_dim1], ldu, &poles[nlf + lvl2 * poles_dim1], & difl[nlf + lvl * difl_dim1], &difr[nlf + lvl2 * difr_dim1], &z__[nlf + lvl * z_dim1], &k[j], &c__[j], &s[j], &work[nwork1], &iwork[iwk], info);
548 }
549 if (*info != 0)
550 {
551 return 0;
552 }
553 /* L40: */
554 }
555 /* L50: */
556 }
557 return 0;
558 /* End of DLASDA */
559 }
560 /* dlasda_ */
561