14 typedef long long BLASLONG;
15 typedef unsigned long long BLASULONG;
17 typedef long BLASLONG;
18 typedef unsigned long BLASULONG;
22 typedef BLASLONG blasint;
24 #define blasabs(x) llabs(x)
26 #define blasabs(x) labs(x)
30 #define blasabs(x) abs(x)
33 typedef blasint integer;
35 typedef unsigned int uinteger;
36 typedef char *address;
37 typedef short int shortint;
39 typedef double doublereal;
40 typedef struct { real r, i; } complex;
41 typedef struct { doublereal r, i; } doublecomplex;
43 static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
44 static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
45 static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
46 static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
48 static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
49 static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
50 static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
51 static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
53 #define pCf(z) (*_pCf(z))
54 #define pCd(z) (*_pCd(z))
56 typedef short int shortlogical;
57 typedef char logical1;
58 typedef char integer1;
63 /* Extern is for use with -E */
74 /*external read, write*/
83 /*internal read, write*/
113 /*rewind, backspace, endfile*/
125 ftnint *inex; /*parameters in standard's order*/
151 union Multitype { /* for multiple entry points */
162 typedef union Multitype Multitype;
164 struct Vardesc { /* for Namelist */
170 typedef struct Vardesc Vardesc;
177 typedef struct Namelist Namelist;
179 #define abs(x) ((x) >= 0 ? (x) : -(x))
180 #define dabs(x) (fabs(x))
181 #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
182 #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
183 #define dmin(a,b) (f2cmin(a,b))
184 #define dmax(a,b) (f2cmax(a,b))
185 #define bit_test(a,b) ((a) >> (b) & 1)
186 #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
187 #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
189 #define abort_() { sig_die("Fortran abort routine called", 1); }
190 #define c_abs(z) (cabsf(Cf(z)))
191 #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
193 #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
194 #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/Cd(b)._Val[1]);}
196 #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
197 #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
199 #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
200 #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
201 #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
202 //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
203 #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
204 #define d_abs(x) (fabs(*(x)))
205 #define d_acos(x) (acos(*(x)))
206 #define d_asin(x) (asin(*(x)))
207 #define d_atan(x) (atan(*(x)))
208 #define d_atn2(x, y) (atan2(*(x),*(y)))
209 #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
210 #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
211 #define d_cos(x) (cos(*(x)))
212 #define d_cosh(x) (cosh(*(x)))
213 #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
214 #define d_exp(x) (exp(*(x)))
215 #define d_imag(z) (cimag(Cd(z)))
216 #define r_imag(z) (cimagf(Cf(z)))
217 #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
218 #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
219 #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
220 #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
221 #define d_log(x) (log(*(x)))
222 #define d_mod(x, y) (fmod(*(x), *(y)))
223 #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
224 #define d_nint(x) u_nint(*(x))
225 #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
226 #define d_sign(a,b) u_sign(*(a),*(b))
227 #define r_sign(a,b) u_sign(*(a),*(b))
228 #define d_sin(x) (sin(*(x)))
229 #define d_sinh(x) (sinh(*(x)))
230 #define d_sqrt(x) (sqrt(*(x)))
231 #define d_tan(x) (tan(*(x)))
232 #define d_tanh(x) (tanh(*(x)))
233 #define i_abs(x) abs(*(x))
234 #define i_dnnt(x) ((integer)u_nint(*(x)))
235 #define i_len(s, n) (n)
236 #define i_nint(x) ((integer)u_nint(*(x)))
237 #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
238 #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
239 #define pow_si(B,E) spow_ui(*(B),*(E))
240 #define pow_ri(B,E) spow_ui(*(B),*(E))
241 #define pow_di(B,E) dpow_ui(*(B),*(E))
242 #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
243 #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
244 #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
245 #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
246 #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
247 #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
248 #define sig_die(s, kill) { exit(1); }
249 #define s_stop(s, n) {exit(0);}
250 static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
251 #define z_abs(z) (cabs(Cd(z)))
252 #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
253 #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
254 #define myexit_() break;
255 #define mycycle_() continue;
256 #define myceiling_(w) {ceil(w)}
257 #define myhuge_(w) {HUGE_VAL}
258 //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
259 #define mymaxloc_(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
261 /* procedure parameter types for -A and -C++ */
263 #define F2C_proc_par_types 1
265 typedef logical (*L_fp)(...);
267 typedef logical (*L_fp)();
270 static float spow_ui(float x, integer n) {
271 float pow=1.0; unsigned long int u;
273 if(n < 0) n = -n, x = 1/x;
282 static double dpow_ui(double x, integer n) {
283 double pow=1.0; unsigned long int u;
285 if(n < 0) n = -n, x = 1/x;
295 static _Fcomplex cpow_ui(complex x, integer n) {
296 complex pow={1.0,0.0}; unsigned long int u;
298 if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
300 if(u & 01) pow.r *= x.r, pow.i *= x.i;
301 if(u >>= 1) x.r *= x.r, x.i *= x.i;
305 _Fcomplex p={pow.r, pow.i};
309 static _Complex float cpow_ui(_Complex float x, integer n) {
310 _Complex float pow=1.0; unsigned long int u;
312 if(n < 0) n = -n, x = 1/x;
323 static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
324 _Dcomplex pow={1.0,0.0}; unsigned long int u;
326 if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
328 if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
329 if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
333 _Dcomplex p = {pow._Val[0], pow._Val[1]};
337 static _Complex double zpow_ui(_Complex double x, integer n) {
338 _Complex double pow=1.0; unsigned long int u;
340 if(n < 0) n = -n, x = 1/x;
350 static integer pow_ii(integer x, integer n) {
351 integer pow; unsigned long int u;
353 if (n == 0 || x == 1) pow = 1;
354 else if (x != -1) pow = x == 0 ? 1/x : 0;
357 if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
367 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
369 double m; integer i, mi;
370 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
371 if (w[i-1]>m) mi=i ,m=w[i-1];
374 static integer smaxloc_(float *w, integer s, integer e, integer *n)
376 float m; integer i, mi;
377 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
378 if (w[i-1]>m) mi=i ,m=w[i-1];
381 static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
382 integer n = *n_, incx = *incx_, incy = *incy_, i;
384 _Fcomplex zdotc = {0.0, 0.0};
385 if (incx == 1 && incy == 1) {
386 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
387 zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
388 zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
391 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
392 zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
393 zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
399 _Complex float zdotc = 0.0;
400 if (incx == 1 && incy == 1) {
401 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
402 zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
405 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
406 zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
412 static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
413 integer n = *n_, incx = *incx_, incy = *incy_, i;
415 _Dcomplex zdotc = {0.0, 0.0};
416 if (incx == 1 && incy == 1) {
417 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
418 zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
419 zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
422 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
423 zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
424 zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
430 _Complex double zdotc = 0.0;
431 if (incx == 1 && incy == 1) {
432 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
433 zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
436 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
437 zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
443 static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
444 integer n = *n_, incx = *incx_, incy = *incy_, i;
446 _Fcomplex zdotc = {0.0, 0.0};
447 if (incx == 1 && incy == 1) {
448 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
449 zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
450 zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
453 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
454 zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
455 zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
461 _Complex float zdotc = 0.0;
462 if (incx == 1 && incy == 1) {
463 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
464 zdotc += Cf(&x[i]) * Cf(&y[i]);
467 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
468 zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
474 static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
475 integer n = *n_, incx = *incx_, incy = *incy_, i;
477 _Dcomplex zdotc = {0.0, 0.0};
478 if (incx == 1 && incy == 1) {
479 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
480 zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
481 zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
484 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
485 zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
486 zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
492 _Complex double zdotc = 0.0;
493 if (incx == 1 && incy == 1) {
494 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
495 zdotc += Cd(&x[i]) * Cd(&y[i]);
498 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
499 zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
505 /* -- translated by f2c (version 20000121).
506 You must link the resulting object file with the libraries:
507 -lf2c -lm (in that order)
513 /* Table of constant values */
515 static integer c_n1 = -1;
516 static integer c__1 = 1;
517 static logical c_false = FALSE_;
519 /* > \brief \b ZUNCSD2BY1 */
521 /* =========== DOCUMENTATION =========== */
523 /* Online html documentation available at */
524 /* http://www.netlib.org/lapack/explore-html/ */
527 /* > Download ZUNCSD2BY1 + dependencies */
528 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zuncsd2
531 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zuncsd2
534 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zuncsd2
542 /* SUBROUTINE ZUNCSD2BY1( JOBU1, JOBU2, JOBV1T, M, P, Q, X11, LDX11, */
543 /* X21, LDX21, THETA, U1, LDU1, U2, LDU2, V1T, */
544 /* LDV1T, WORK, LWORK, RWORK, LRWORK, IWORK, */
547 /* CHARACTER JOBU1, JOBU2, JOBV1T */
548 /* INTEGER INFO, LDU1, LDU2, LDV1T, LWORK, LDX11, LDX21, */
550 /* INTEGER LRWORK, LRWORKMIN, LRWORKOPT */
551 /* DOUBLE PRECISION RWORK(*) */
552 /* DOUBLE PRECISION THETA(*) */
553 /* COMPLEX*16 U1(LDU1,*), U2(LDU2,*), V1T(LDV1T,*), WORK(*), */
554 /* $ X11(LDX11,*), X21(LDX21,*) */
555 /* INTEGER IWORK(*) */
558 /* > \par Purpose: */
563 /* > ZUNCSD2BY1 computes the CS decomposition of an M-by-Q matrix X with */
564 /* > orthonormal columns that has been partitioned into a 2-by-1 block */
569 /* > [ X11 ] [ U1 | ] [ 0 0 0 ] */
570 /* > X = [-----] = [---------] [----------] V1**T . */
571 /* > [ X21 ] [ | U2 ] [ 0 0 0 ] */
575 /* > X11 is P-by-Q. The unitary matrices U1, U2, and V1 are P-by-P, */
576 /* > (M-P)-by-(M-P), and Q-by-Q, respectively. C and S are R-by-R */
577 /* > nonnegative diagonal matrices satisfying C^2 + S^2 = I, in which */
578 /* > R = MIN(P,M-P,Q,M-Q). I1 is a K1-by-K1 identity matrix and I2 is a */
579 /* > K2-by-K2 identity matrix, where K1 = MAX(Q+P-M,0), K2 = MAX(Q-P,0). */
585 /* > \param[in] JOBU1 */
587 /* > JOBU1 is CHARACTER */
588 /* > = 'Y': U1 is computed; */
589 /* > otherwise: U1 is not computed. */
592 /* > \param[in] JOBU2 */
594 /* > JOBU2 is CHARACTER */
595 /* > = 'Y': U2 is computed; */
596 /* > otherwise: U2 is not computed. */
599 /* > \param[in] JOBV1T */
601 /* > JOBV1T is CHARACTER */
602 /* > = 'Y': V1T is computed; */
603 /* > otherwise: V1T is not computed. */
609 /* > The number of rows in X. */
615 /* > The number of rows in X11. 0 <= P <= M. */
621 /* > The number of columns in X11 and X21. 0 <= Q <= M. */
624 /* > \param[in,out] X11 */
626 /* > X11 is COMPLEX*16 array, dimension (LDX11,Q) */
627 /* > On entry, part of the unitary matrix whose CSD is desired. */
630 /* > \param[in] LDX11 */
632 /* > LDX11 is INTEGER */
633 /* > The leading dimension of X11. LDX11 >= MAX(1,P). */
636 /* > \param[in,out] X21 */
638 /* > X21 is COMPLEX*16 array, dimension (LDX21,Q) */
639 /* > On entry, part of the unitary matrix whose CSD is desired. */
642 /* > \param[in] LDX21 */
644 /* > LDX21 is INTEGER */
645 /* > The leading dimension of X21. LDX21 >= MAX(1,M-P). */
648 /* > \param[out] THETA */
650 /* > THETA is DOUBLE PRECISION array, dimension (R), in which R = */
651 /* > MIN(P,M-P,Q,M-Q). */
652 /* > C = DIAG( COS(THETA(1)), ... , COS(THETA(R)) ) and */
653 /* > S = DIAG( SIN(THETA(1)), ... , SIN(THETA(R)) ). */
656 /* > \param[out] U1 */
658 /* > U1 is COMPLEX*16 array, dimension (P) */
659 /* > If JOBU1 = 'Y', U1 contains the P-by-P unitary matrix U1. */
662 /* > \param[in] LDU1 */
664 /* > LDU1 is INTEGER */
665 /* > The leading dimension of U1. If JOBU1 = 'Y', LDU1 >= */
669 /* > \param[out] U2 */
671 /* > U2 is COMPLEX*16 array, dimension (M-P) */
672 /* > If JOBU2 = 'Y', U2 contains the (M-P)-by-(M-P) unitary */
676 /* > \param[in] LDU2 */
678 /* > LDU2 is INTEGER */
679 /* > The leading dimension of U2. If JOBU2 = 'Y', LDU2 >= */
683 /* > \param[out] V1T */
685 /* > V1T is COMPLEX*16 array, dimension (Q) */
686 /* > If JOBV1T = 'Y', V1T contains the Q-by-Q matrix unitary */
687 /* > matrix V1**T. */
690 /* > \param[in] LDV1T */
692 /* > LDV1T is INTEGER */
693 /* > The leading dimension of V1T. If JOBV1T = 'Y', LDV1T >= */
697 /* > \param[out] WORK */
699 /* > WORK is COMPLEX*16 array, dimension (MAX(1,LWORK)) */
700 /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
703 /* > \param[in] LWORK */
705 /* > LWORK is INTEGER */
706 /* > The dimension of the array WORK. */
708 /* > If LWORK = -1, then a workspace query is assumed; the routine */
709 /* > only calculates the optimal size of the WORK array, returns */
710 /* > this value as the first entry of the work array, and no error */
711 /* > message related to LWORK is issued by XERBLA. */
714 /* > \param[out] RWORK */
716 /* > RWORK is DOUBLE PRECISION array, dimension (MAX(1,LRWORK)) */
717 /* > On exit, if INFO = 0, RWORK(1) returns the optimal LRWORK. */
718 /* > If INFO > 0 on exit, RWORK(2:R) contains the values PHI(1), */
719 /* > ..., PHI(R-1) that, together with THETA(1), ..., THETA(R), */
720 /* > define the matrix in intermediate bidiagonal-block form */
721 /* > remaining after nonconvergence. INFO specifies the number */
722 /* > of nonzero PHI's. */
725 /* > \param[in] LRWORK */
727 /* > LRWORK is INTEGER */
728 /* > The dimension of the array RWORK. */
730 /* > If LRWORK = -1, then a workspace query is assumed; the routine */
731 /* > only calculates the optimal size of the RWORK array, returns */
732 /* > this value as the first entry of the work array, and no error */
733 /* > message related to LRWORK is issued by XERBLA. */
736 /* > \param[out] IWORK */
738 /* > IWORK is INTEGER array, dimension (M-MIN(P,M-P,Q,M-Q)) */
741 /* > \param[out] INFO */
743 /* > INFO is INTEGER */
744 /* > = 0: successful exit. */
745 /* > < 0: if INFO = -i, the i-th argument had an illegal value. */
746 /* > > 0: ZBBCSD did not converge. See the description of WORK */
747 /* > above for details. */
750 /* > \par References: */
751 /* ================ */
753 /* > [1] Brian D. Sutton. Computing the complete CS decomposition. Numer. */
754 /* > Algorithms, 50(1):33-65, 2009. */
759 /* > \author Univ. of Tennessee */
760 /* > \author Univ. of California Berkeley */
761 /* > \author Univ. of Colorado Denver */
762 /* > \author NAG Ltd. */
764 /* > \date July 2012 */
766 /* > \ingroup complex16OTHERcomputational */
768 /* ===================================================================== */
769 /* Subroutine */ int zuncsd2by1_(char *jobu1, char *jobu2, char *jobv1t,
770 integer *m, integer *p, integer *q, doublecomplex *x11, integer *
771 ldx11, doublecomplex *x21, integer *ldx21, doublereal *theta,
772 doublecomplex *u1, integer *ldu1, doublecomplex *u2, integer *ldu2,
773 doublecomplex *v1t, integer *ldv1t, doublecomplex *work, integer *
774 lwork, doublereal *rwork, integer *lrwork, integer *iwork, integer *
777 /* System generated locals */
778 integer u1_dim1, u1_offset, u2_dim1, u2_offset, v1t_dim1, v1t_offset,
779 x11_dim1, x11_offset, x21_dim1, x21_offset, i__1, i__2, i__3;
781 /* Local variables */
782 integer ib11d, ib11e, ib12d, ib12e, ib21d, ib21e, ib22d, ib22e;
783 doublecomplex cdum[1] /* was [1][1] */;
784 integer iphi, lworkmin, lworkopt, i__, j, r__;
785 extern logical lsame_(char *, char *);
787 extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *,
788 doublecomplex *, integer *);
789 integer lorglqmin, lorgqrmin, lorglqopt, lrworkmin, itaup1, itaup2,
791 logical wantu1, wantu2;
792 integer lrworkopt, ibbcsd, lbbcsd, iorbdb, lorbdb;
793 extern /* Subroutine */ int zbbcsd_(char *, char *, char *, char *, char *
794 , integer *, integer *, integer *, doublereal *, doublereal *,
795 doublecomplex *, integer *, doublecomplex *, integer *,
796 doublecomplex *, integer *, doublecomplex *, integer *,
797 doublereal *, doublereal *, doublereal *, doublereal *,
798 doublereal *, doublereal *, doublereal *, doublereal *,
799 doublereal *, integer *, integer *), xerbla_(char *, integer *, ftnlen);
800 integer iorglq, lorglq;
801 extern /* Subroutine */ int zlacpy_(char *, integer *, integer *,
802 doublecomplex *, integer *, doublecomplex *, integer *);
804 extern /* Subroutine */ int zlapmr_(logical *, integer *, integer *,
805 doublecomplex *, integer *, integer *);
807 extern /* Subroutine */ int zlapmt_(logical *, integer *, integer *,
808 doublecomplex *, integer *, integer *);
810 extern /* Subroutine */ int zunglq_(integer *, integer *, integer *,
811 doublecomplex *, integer *, doublecomplex *, doublecomplex *,
812 integer *, integer *), zungqr_(integer *, integer *, integer *,
813 doublecomplex *, integer *, doublecomplex *, doublecomplex *,
814 integer *, integer *), zunbdb1_(integer *, integer *, integer *,
815 doublecomplex *, integer *, doublecomplex *, integer *,
816 doublereal *, doublereal *, doublecomplex *, doublecomplex *,
817 doublecomplex *, doublecomplex *, integer *, integer *), zunbdb2_(
818 integer *, integer *, integer *, doublecomplex *, integer *,
819 doublecomplex *, integer *, doublereal *, doublereal *,
820 doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
821 , integer *, integer *), zunbdb3_(integer *, integer *, integer *,
822 doublecomplex *, integer *, doublecomplex *, integer *,
823 doublereal *, doublereal *, doublecomplex *, doublecomplex *,
824 doublecomplex *, doublecomplex *, integer *, integer *), zunbdb4_(
825 integer *, integer *, integer *, doublecomplex *, integer *,
826 doublecomplex *, integer *, doublereal *, doublereal *,
827 doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
828 , doublecomplex *, integer *, integer *);
833 /* -- LAPACK computational routine (version 3.7.1) -- */
834 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
835 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
839 /* ===================================================================== */
842 /* Test input arguments */
844 /* Parameter adjustments */
846 x11_offset = 1 + x11_dim1 * 1;
849 x21_offset = 1 + x21_dim1 * 1;
853 u1_offset = 1 + u1_dim1 * 1;
856 u2_offset = 1 + u2_dim1 * 1;
859 v1t_offset = 1 + v1t_dim1 * 1;
867 wantu1 = lsame_(jobu1, "Y");
868 wantu2 = lsame_(jobu2, "Y");
869 wantv1t = lsame_(jobv1t, "Y");
870 lquery = *lwork == -1;
874 } else if (*p < 0 || *p > *m) {
876 } else if (*q < 0 || *q > *m) {
878 } else if (*ldx11 < f2cmax(1,*p)) {
880 } else /* if(complicated condition) */ {
882 i__1 = 1, i__2 = *m - *p;
883 if (*ldx21 < f2cmax(i__1,i__2)) {
885 } else if (wantu1 && *ldu1 < f2cmax(1,*p)) {
887 } else /* if(complicated condition) */ {
889 i__1 = 1, i__2 = *m - *p;
890 if (wantu2 && *ldu2 < f2cmax(i__1,i__2)) {
892 } else if (wantv1t && *ldv1t < f2cmax(1,*q)) {
899 i__1 = *p, i__2 = *m - *p, i__1 = f2cmin(i__1,i__2), i__1 = f2cmin(i__1,*q),
901 r__ = f2cmin(i__1,i__2);
903 /* Compute workspace */
906 /* |-----------------------------------------| */
907 /* | LWORKOPT (1) | */
908 /* |-----------------------------------------| */
909 /* | TAUP1 (MAX(1,P)) | */
910 /* | TAUP2 (MAX(1,M-P)) | */
911 /* | TAUQ1 (MAX(1,Q)) | */
912 /* |-----------------------------------------| */
913 /* | ZUNBDB WORK | ZUNGQR WORK | ZUNGLQ WORK | */
918 /* |-----------------------------------------| */
920 /* |------------------| */
921 /* | LRWORKOPT (1) | */
922 /* |------------------| */
923 /* | PHI (MAX(1,R-1)) | */
924 /* |------------------| */
933 /* | ZBBCSD RWORK | */
934 /* |------------------| */
939 i__1 = 1, i__2 = r__ - 1;
940 ib11d = iphi + f2cmax(i__1,i__2);
941 ib11e = ib11d + f2cmax(1,r__);
943 i__1 = 1, i__2 = r__ - 1;
944 ib12d = ib11e + f2cmax(i__1,i__2);
945 ib12e = ib12d + f2cmax(1,r__);
947 i__1 = 1, i__2 = r__ - 1;
948 ib21d = ib12e + f2cmax(i__1,i__2);
949 ib21e = ib21d + f2cmax(1,r__);
951 i__1 = 1, i__2 = r__ - 1;
952 ib22d = ib21e + f2cmax(i__1,i__2);
953 ib22e = ib22d + f2cmax(1,r__);
955 i__1 = 1, i__2 = r__ - 1;
956 ibbcsd = ib22e + f2cmax(i__1,i__2);
958 itaup2 = itaup1 + f2cmax(1,*p);
960 i__1 = 1, i__2 = *m - *p;
961 itauq1 = itaup2 + f2cmax(i__1,i__2);
962 iorbdb = itauq1 + f2cmax(1,*q);
963 iorgqr = itauq1 + f2cmax(1,*q);
964 iorglq = itauq1 + f2cmax(1,*q);
970 zunbdb1_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset],
971 ldx21, &theta[1], dum, cdum, cdum, cdum, &work[1], &c_n1,
973 lorbdb = (integer) work[1].r;
974 if (wantu1 && *p > 0) {
975 zungqr_(p, p, q, &u1[u1_offset], ldu1, cdum, &work[1], &c_n1,
977 lorgqrmin = f2cmax(lorgqrmin,*p);
979 i__1 = lorgqropt, i__2 = (integer) work[1].r;
980 lorgqropt = f2cmax(i__1,i__2);
982 if (wantu2 && *m - *p > 0) {
985 zungqr_(&i__1, &i__2, q, &u2[u2_offset], ldu2, cdum, &work[1],
988 i__1 = lorgqrmin, i__2 = *m - *p;
989 lorgqrmin = f2cmax(i__1,i__2);
991 i__1 = lorgqropt, i__2 = (integer) work[1].r;
992 lorgqropt = f2cmax(i__1,i__2);
994 if (wantv1t && *q > 0) {
998 zunglq_(&i__1, &i__2, &i__3, &v1t[v1t_offset], ldv1t, cdum, &
999 work[1], &c_n1, &childinfo);
1001 i__1 = lorglqmin, i__2 = *q - 1;
1002 lorglqmin = f2cmax(i__1,i__2);
1004 i__1 = lorglqopt, i__2 = (integer) work[1].r;
1005 lorglqopt = f2cmax(i__1,i__2);
1007 zbbcsd_(jobu1, jobu2, jobv1t, "N", "N", m, p, q, &theta[1], dum, &
1008 u1[u1_offset], ldu1, &u2[u2_offset], ldu2, &v1t[
1009 v1t_offset], ldv1t, cdum, &c__1, dum, dum, dum, dum, dum,
1010 dum, dum, dum, &rwork[1], &c_n1, &childinfo);
1011 lbbcsd = (integer) rwork[1];
1012 } else if (r__ == *p) {
1013 zunbdb2_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset],
1014 ldx21, &theta[1], dum, cdum, cdum, cdum, &work[1], &c_n1,
1016 lorbdb = (integer) work[1].r;
1017 if (wantu1 && *p > 0) {
1021 zungqr_(&i__1, &i__2, &i__3, &u1[(u1_dim1 << 1) + 2], ldu1,
1022 cdum, &work[1], &c_n1, &childinfo);
1024 i__1 = lorgqrmin, i__2 = *p - 1;
1025 lorgqrmin = f2cmax(i__1,i__2);
1027 i__1 = lorgqropt, i__2 = (integer) work[1].r;
1028 lorgqropt = f2cmax(i__1,i__2);
1030 if (wantu2 && *m - *p > 0) {
1033 zungqr_(&i__1, &i__2, q, &u2[u2_offset], ldu2, cdum, &work[1],
1036 i__1 = lorgqrmin, i__2 = *m - *p;
1037 lorgqrmin = f2cmax(i__1,i__2);
1039 i__1 = lorgqropt, i__2 = (integer) work[1].r;
1040 lorgqropt = f2cmax(i__1,i__2);
1042 if (wantv1t && *q > 0) {
1043 zunglq_(q, q, &r__, &v1t[v1t_offset], ldv1t, cdum, &work[1], &
1045 lorglqmin = f2cmax(lorglqmin,*q);
1047 i__1 = lorglqopt, i__2 = (integer) work[1].r;
1048 lorglqopt = f2cmax(i__1,i__2);
1050 zbbcsd_(jobv1t, "N", jobu1, jobu2, "T", m, q, p, &theta[1], dum, &
1051 v1t[v1t_offset], ldv1t, cdum, &c__1, &u1[u1_offset], ldu1,
1052 &u2[u2_offset], ldu2, dum, dum, dum, dum, dum, dum, dum,
1053 dum, &rwork[1], &c_n1, &childinfo);
1054 lbbcsd = (integer) rwork[1];
1055 } else if (r__ == *m - *p) {
1056 zunbdb3_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset],
1057 ldx21, &theta[1], dum, cdum, cdum, cdum, &work[1], &c_n1,
1059 lorbdb = (integer) work[1].r;
1060 if (wantu1 && *p > 0) {
1061 zungqr_(p, p, q, &u1[u1_offset], ldu1, cdum, &work[1], &c_n1,
1063 lorgqrmin = f2cmax(lorgqrmin,*p);
1065 i__1 = lorgqropt, i__2 = (integer) work[1].r;
1066 lorgqropt = f2cmax(i__1,i__2);
1068 if (wantu2 && *m - *p > 0) {
1072 zungqr_(&i__1, &i__2, &i__3, &u2[(u2_dim1 << 1) + 2], ldu2,
1073 cdum, &work[1], &c_n1, &childinfo);
1075 i__1 = lorgqrmin, i__2 = *m - *p - 1;
1076 lorgqrmin = f2cmax(i__1,i__2);
1078 i__1 = lorgqropt, i__2 = (integer) work[1].r;
1079 lorgqropt = f2cmax(i__1,i__2);
1081 if (wantv1t && *q > 0) {
1082 zunglq_(q, q, &r__, &v1t[v1t_offset], ldv1t, cdum, &work[1], &
1084 lorglqmin = f2cmax(lorglqmin,*q);
1086 i__1 = lorglqopt, i__2 = (integer) work[1].r;
1087 lorglqopt = f2cmax(i__1,i__2);
1091 zbbcsd_("N", jobv1t, jobu2, jobu1, "T", m, &i__1, &i__2, &theta[1]
1092 , dum, cdum, &c__1, &v1t[v1t_offset], ldv1t, &u2[
1093 u2_offset], ldu2, &u1[u1_offset], ldu1, dum, dum, dum,
1094 dum, dum, dum, dum, dum, &rwork[1], &c_n1, &childinfo);
1095 lbbcsd = (integer) rwork[1];
1097 zunbdb4_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset],
1098 ldx21, &theta[1], dum, cdum, cdum, cdum, cdum, &work[1], &
1100 lorbdb = *m + (integer) work[1].r;
1101 if (wantu1 && *p > 0) {
1103 zungqr_(p, p, &i__1, &u1[u1_offset], ldu1, cdum, &work[1], &
1105 lorgqrmin = f2cmax(lorgqrmin,*p);
1107 i__1 = lorgqropt, i__2 = (integer) work[1].r;
1108 lorgqropt = f2cmax(i__1,i__2);
1110 if (wantu2 && *m - *p > 0) {
1114 zungqr_(&i__1, &i__2, &i__3, &u2[u2_offset], ldu2, cdum, &
1115 work[1], &c_n1, &childinfo);
1117 i__1 = lorgqrmin, i__2 = *m - *p;
1118 lorgqrmin = f2cmax(i__1,i__2);
1120 i__1 = lorgqropt, i__2 = (integer) work[1].r;
1121 lorgqropt = f2cmax(i__1,i__2);
1123 if (wantv1t && *q > 0) {
1124 zunglq_(q, q, q, &v1t[v1t_offset], ldv1t, cdum, &work[1], &
1126 lorglqmin = f2cmax(lorglqmin,*q);
1128 i__1 = lorglqopt, i__2 = (integer) work[1].r;
1129 lorglqopt = f2cmax(i__1,i__2);
1133 zbbcsd_(jobu2, jobu1, "N", jobv1t, "N", m, &i__1, &i__2, &theta[1]
1134 , dum, &u2[u2_offset], ldu2, &u1[u1_offset], ldu1, cdum, &
1135 c__1, &v1t[v1t_offset], ldv1t, dum, dum, dum, dum, dum,
1136 dum, dum, dum, &rwork[1], &c_n1, &childinfo);
1137 lbbcsd = (integer) rwork[1];
1139 lrworkmin = ibbcsd + lbbcsd - 1;
1140 lrworkopt = lrworkmin;
1141 rwork[1] = (doublereal) lrworkopt;
1143 i__1 = iorbdb + lorbdb - 1, i__2 = iorgqr + lorgqrmin - 1, i__1 = f2cmax(
1144 i__1,i__2), i__2 = iorglq + lorglqmin - 1;
1145 lworkmin = f2cmax(i__1,i__2);
1147 i__1 = iorbdb + lorbdb - 1, i__2 = iorgqr + lorgqropt - 1, i__1 = f2cmax(
1148 i__1,i__2), i__2 = iorglq + lorglqopt - 1;
1149 lworkopt = f2cmax(i__1,i__2);
1150 work[1].r = (doublereal) lworkopt, work[1].i = 0.;
1151 if (*lwork < lworkmin && ! lquery) {
1157 xerbla_("ZUNCSD2BY1", &i__1, (ftnlen)10);
1159 } else if (lquery) {
1162 lorgqr = *lwork - iorgqr + 1;
1163 lorglq = *lwork - iorglq + 1;
1165 /* Handle four cases separately: R = Q, R = P, R = M-P, and R = M-Q, */
1166 /* in which R = MIN(P,M-P,Q,M-Q) */
1172 /* Simultaneously bidiagonalize X11 and X21 */
1174 zunbdb1_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset], ldx21, &
1175 theta[1], &rwork[iphi], &work[itaup1], &work[itaup2], &work[
1176 itauq1], &work[iorbdb], &lorbdb, &childinfo);
1178 /* Accumulate Householder reflectors */
1180 if (wantu1 && *p > 0) {
1181 zlacpy_("L", p, q, &x11[x11_offset], ldx11, &u1[u1_offset], ldu1);
1182 zungqr_(p, p, q, &u1[u1_offset], ldu1, &work[itaup1], &work[
1183 iorgqr], &lorgqr, &childinfo);
1185 if (wantu2 && *m - *p > 0) {
1187 zlacpy_("L", &i__1, q, &x21[x21_offset], ldx21, &u2[u2_offset],
1191 zungqr_(&i__1, &i__2, q, &u2[u2_offset], ldu2, &work[itaup2], &
1192 work[iorgqr], &lorgqr, &childinfo);
1194 if (wantv1t && *q > 0) {
1195 i__1 = v1t_dim1 + 1;
1196 v1t[i__1].r = 1., v1t[i__1].i = 0.;
1198 for (j = 2; j <= i__1; ++j) {
1199 i__2 = j * v1t_dim1 + 1;
1200 v1t[i__2].r = 0., v1t[i__2].i = 0.;
1201 i__2 = j + v1t_dim1;
1202 v1t[i__2].r = 0., v1t[i__2].i = 0.;
1206 zlacpy_("U", &i__1, &i__2, &x21[(x21_dim1 << 1) + 1], ldx21, &v1t[
1207 (v1t_dim1 << 1) + 2], ldv1t);
1211 zunglq_(&i__1, &i__2, &i__3, &v1t[(v1t_dim1 << 1) + 2], ldv1t, &
1212 work[itauq1], &work[iorglq], &lorglq, &childinfo);
1215 /* Simultaneously diagonalize X11 and X21. */
1217 zbbcsd_(jobu1, jobu2, jobv1t, "N", "N", m, p, q, &theta[1], &rwork[
1218 iphi], &u1[u1_offset], ldu1, &u2[u2_offset], ldu2, &v1t[
1219 v1t_offset], ldv1t, cdum, &c__1, &rwork[ib11d], &rwork[ib11e],
1220 &rwork[ib12d], &rwork[ib12e], &rwork[ib21d], &rwork[ib21e], &
1221 rwork[ib22d], &rwork[ib22e], &rwork[ibbcsd], &lbbcsd, &
1224 /* Permute rows and columns to place zero submatrices in */
1225 /* preferred positions */
1227 if (*q > 0 && wantu2) {
1229 for (i__ = 1; i__ <= i__1; ++i__) {
1230 iwork[i__] = *m - *p - *q + i__;
1233 for (i__ = *q + 1; i__ <= i__1; ++i__) {
1234 iwork[i__] = i__ - *q;
1238 zlapmt_(&c_false, &i__1, &i__2, &u2[u2_offset], ldu2, &iwork[1]);
1240 } else if (r__ == *p) {
1244 /* Simultaneously bidiagonalize X11 and X21 */
1246 zunbdb2_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset], ldx21, &
1247 theta[1], &rwork[iphi], &work[itaup1], &work[itaup2], &work[
1248 itauq1], &work[iorbdb], &lorbdb, &childinfo);
1250 /* Accumulate Householder reflectors */
1252 if (wantu1 && *p > 0) {
1254 u1[i__1].r = 1., u1[i__1].i = 0.;
1256 for (j = 2; j <= i__1; ++j) {
1257 i__2 = j * u1_dim1 + 1;
1258 u1[i__2].r = 0., u1[i__2].i = 0.;
1260 u1[i__2].r = 0., u1[i__2].i = 0.;
1264 zlacpy_("L", &i__1, &i__2, &x11[x11_dim1 + 2], ldx11, &u1[(
1265 u1_dim1 << 1) + 2], ldu1);
1269 zungqr_(&i__1, &i__2, &i__3, &u1[(u1_dim1 << 1) + 2], ldu1, &work[
1270 itaup1], &work[iorgqr], &lorgqr, &childinfo);
1272 if (wantu2 && *m - *p > 0) {
1274 zlacpy_("L", &i__1, q, &x21[x21_offset], ldx21, &u2[u2_offset],
1278 zungqr_(&i__1, &i__2, q, &u2[u2_offset], ldu2, &work[itaup2], &
1279 work[iorgqr], &lorgqr, &childinfo);
1281 if (wantv1t && *q > 0) {
1282 zlacpy_("U", p, q, &x11[x11_offset], ldx11, &v1t[v1t_offset],
1284 zunglq_(q, q, &r__, &v1t[v1t_offset], ldv1t, &work[itauq1], &work[
1285 iorglq], &lorglq, &childinfo);
1288 /* Simultaneously diagonalize X11 and X21. */
1290 zbbcsd_(jobv1t, "N", jobu1, jobu2, "T", m, q, p, &theta[1], &rwork[
1291 iphi], &v1t[v1t_offset], ldv1t, cdum, &c__1, &u1[u1_offset],
1292 ldu1, &u2[u2_offset], ldu2, &rwork[ib11d], &rwork[ib11e], &
1293 rwork[ib12d], &rwork[ib12e], &rwork[ib21d], &rwork[ib21e], &
1294 rwork[ib22d], &rwork[ib22e], &rwork[ibbcsd], &lbbcsd, &
1297 /* Permute rows and columns to place identity submatrices in */
1298 /* preferred positions */
1300 if (*q > 0 && wantu2) {
1302 for (i__ = 1; i__ <= i__1; ++i__) {
1303 iwork[i__] = *m - *p - *q + i__;
1306 for (i__ = *q + 1; i__ <= i__1; ++i__) {
1307 iwork[i__] = i__ - *q;
1311 zlapmt_(&c_false, &i__1, &i__2, &u2[u2_offset], ldu2, &iwork[1]);
1313 } else if (r__ == *m - *p) {
1315 /* Case 3: R = M-P */
1317 /* Simultaneously bidiagonalize X11 and X21 */
1319 zunbdb3_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset], ldx21, &
1320 theta[1], &rwork[iphi], &work[itaup1], &work[itaup2], &work[
1321 itauq1], &work[iorbdb], &lorbdb, &childinfo);
1323 /* Accumulate Householder reflectors */
1325 if (wantu1 && *p > 0) {
1326 zlacpy_("L", p, q, &x11[x11_offset], ldx11, &u1[u1_offset], ldu1);
1327 zungqr_(p, p, q, &u1[u1_offset], ldu1, &work[itaup1], &work[
1328 iorgqr], &lorgqr, &childinfo);
1330 if (wantu2 && *m - *p > 0) {
1332 u2[i__1].r = 1., u2[i__1].i = 0.;
1334 for (j = 2; j <= i__1; ++j) {
1335 i__2 = j * u2_dim1 + 1;
1336 u2[i__2].r = 0., u2[i__2].i = 0.;
1338 u2[i__2].r = 0., u2[i__2].i = 0.;
1342 zlacpy_("L", &i__1, &i__2, &x21[x21_dim1 + 2], ldx21, &u2[(
1343 u2_dim1 << 1) + 2], ldu2);
1347 zungqr_(&i__1, &i__2, &i__3, &u2[(u2_dim1 << 1) + 2], ldu2, &work[
1348 itaup2], &work[iorgqr], &lorgqr, &childinfo);
1350 if (wantv1t && *q > 0) {
1352 zlacpy_("U", &i__1, q, &x21[x21_offset], ldx21, &v1t[v1t_offset],
1354 zunglq_(q, q, &r__, &v1t[v1t_offset], ldv1t, &work[itauq1], &work[
1355 iorglq], &lorglq, &childinfo);
1358 /* Simultaneously diagonalize X11 and X21. */
1362 zbbcsd_("N", jobv1t, jobu2, jobu1, "T", m, &i__1, &i__2, &theta[1], &
1363 rwork[iphi], cdum, &c__1, &v1t[v1t_offset], ldv1t, &u2[
1364 u2_offset], ldu2, &u1[u1_offset], ldu1, &rwork[ib11d], &rwork[
1365 ib11e], &rwork[ib12d], &rwork[ib12e], &rwork[ib21d], &rwork[
1366 ib21e], &rwork[ib22d], &rwork[ib22e], &rwork[ibbcsd], &lbbcsd,
1369 /* Permute rows and columns to place identity submatrices in */
1370 /* preferred positions */
1374 for (i__ = 1; i__ <= i__1; ++i__) {
1375 iwork[i__] = *q - r__ + i__;
1378 for (i__ = r__ + 1; i__ <= i__1; ++i__) {
1379 iwork[i__] = i__ - r__;
1382 zlapmt_(&c_false, p, q, &u1[u1_offset], ldu1, &iwork[1]);
1385 zlapmr_(&c_false, q, q, &v1t[v1t_offset], ldv1t, &iwork[1]);
1390 /* Case 4: R = M-Q */
1392 /* Simultaneously bidiagonalize X11 and X21 */
1395 zunbdb4_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset], ldx21, &
1396 theta[1], &rwork[iphi], &work[itaup1], &work[itaup2], &work[
1397 itauq1], &work[iorbdb], &work[iorbdb + *m], &i__1, &childinfo)
1400 /* Accumulate Householder reflectors */
1402 if (wantu1 && *p > 0) {
1403 zcopy_(p, &work[iorbdb], &c__1, &u1[u1_offset], &c__1);
1405 for (j = 2; j <= i__1; ++j) {
1406 i__2 = j * u1_dim1 + 1;
1407 u1[i__2].r = 0., u1[i__2].i = 0.;
1411 zlacpy_("L", &i__1, &i__2, &x11[x11_dim1 + 2], ldx11, &u1[(
1412 u1_dim1 << 1) + 2], ldu1);
1414 zungqr_(p, p, &i__1, &u1[u1_offset], ldu1, &work[itaup1], &work[
1415 iorgqr], &lorgqr, &childinfo);
1417 if (wantu2 && *m - *p > 0) {
1419 zcopy_(&i__1, &work[iorbdb + *p], &c__1, &u2[u2_offset], &c__1);
1421 for (j = 2; j <= i__1; ++j) {
1422 i__2 = j * u2_dim1 + 1;
1423 u2[i__2].r = 0., u2[i__2].i = 0.;
1427 zlacpy_("L", &i__1, &i__2, &x21[x21_dim1 + 2], ldx21, &u2[(
1428 u2_dim1 << 1) + 2], ldu2);
1432 zungqr_(&i__1, &i__2, &i__3, &u2[u2_offset], ldu2, &work[itaup2],
1433 &work[iorgqr], &lorgqr, &childinfo);
1435 if (wantv1t && *q > 0) {
1437 zlacpy_("U", &i__1, q, &x21[x21_offset], ldx21, &v1t[v1t_offset],
1439 i__1 = *p - (*m - *q);
1440 i__2 = *q - (*m - *q);
1441 zlacpy_("U", &i__1, &i__2, &x11[*m - *q + 1 + (*m - *q + 1) *
1442 x11_dim1], ldx11, &v1t[*m - *q + 1 + (*m - *q + 1) *
1446 zlacpy_("U", &i__1, &i__2, &x21[*m - *q + 1 + (*p + 1) * x21_dim1]
1447 , ldx21, &v1t[*p + 1 + (*p + 1) * v1t_dim1], ldv1t);
1448 zunglq_(q, q, q, &v1t[v1t_offset], ldv1t, &work[itauq1], &work[
1449 iorglq], &lorglq, &childinfo);
1452 /* Simultaneously diagonalize X11 and X21. */
1456 zbbcsd_(jobu2, jobu1, "N", jobv1t, "N", m, &i__1, &i__2, &theta[1], &
1457 rwork[iphi], &u2[u2_offset], ldu2, &u1[u1_offset], ldu1, cdum,
1458 &c__1, &v1t[v1t_offset], ldv1t, &rwork[ib11d], &rwork[ib11e],
1459 &rwork[ib12d], &rwork[ib12e], &rwork[ib21d], &rwork[ib21e], &
1460 rwork[ib22d], &rwork[ib22e], &rwork[ibbcsd], &lbbcsd, &
1463 /* Permute rows and columns to place identity submatrices in */
1464 /* preferred positions */
1468 for (i__ = 1; i__ <= i__1; ++i__) {
1469 iwork[i__] = *p - r__ + i__;
1472 for (i__ = r__ + 1; i__ <= i__1; ++i__) {
1473 iwork[i__] = i__ - r__;
1476 zlapmt_(&c_false, p, p, &u1[u1_offset], ldu1, &iwork[1]);
1479 zlapmr_(&c_false, p, q, &v1t[v1t_offset], ldv1t, &iwork[1]);
1486 /* End of ZUNCSD2BY1 */