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]/df(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 SORCSD2BY1 */
521 /* =========== DOCUMENTATION =========== */
523 /* Online html documentation available at */
524 /* http://www.netlib.org/lapack/explore-html/ */
527 /* > Download SORCSD2BY1 + dependencies */
528 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sorcsd2
531 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sorcsd2
534 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sorcsd2
542 /* SUBROUTINE SORCSD2BY1( JOBU1, JOBU2, JOBV1T, M, P, Q, X11, LDX11, */
543 /* X21, LDX21, THETA, U1, LDU1, U2, LDU2, V1T, */
544 /* LDV1T, WORK, LWORK, IWORK, INFO ) */
546 /* CHARACTER JOBU1, JOBU2, JOBV1T */
547 /* INTEGER INFO, LDU1, LDU2, LDV1T, LWORK, LDX11, LDX21, */
550 /* REAL U1(LDU1,*), U2(LDU2,*), V1T(LDV1T,*), WORK(*), */
551 /* $ X11(LDX11,*), X21(LDX21,*) */
552 /* INTEGER IWORK(*) */
555 /* > \par Purpose: */
560 /* > SORCSD2BY1 computes the CS decomposition of an M-by-Q matrix X with */
561 /* > orthonormal columns that has been partitioned into a 2-by-1 block */
566 /* > [ X11 ] [ U1 | ] [ 0 0 0 ] */
567 /* > X = [-----] = [---------] [----------] V1**T . */
568 /* > [ X21 ] [ | U2 ] [ 0 0 0 ] */
572 /* > X11 is P-by-Q. The orthogonal matrices U1, U2, and V1 are P-by-P, */
573 /* > (M-P)-by-(M-P), and Q-by-Q, respectively. C and S are R-by-R */
574 /* > nonnegative diagonal matrices satisfying C^2 + S^2 = I, in which */
575 /* > R = MIN(P,M-P,Q,M-Q). I1 is a K1-by-K1 identity matrix and I2 is a */
576 /* > K2-by-K2 identity matrix, where K1 = MAX(Q+P-M,0), K2 = MAX(Q-P,0). */
582 /* > \param[in] JOBU1 */
584 /* > JOBU1 is CHARACTER */
585 /* > = 'Y': U1 is computed; */
586 /* > otherwise: U1 is not computed. */
589 /* > \param[in] JOBU2 */
591 /* > JOBU2 is CHARACTER */
592 /* > = 'Y': U2 is computed; */
593 /* > otherwise: U2 is not computed. */
596 /* > \param[in] JOBV1T */
598 /* > JOBV1T is CHARACTER */
599 /* > = 'Y': V1T is computed; */
600 /* > otherwise: V1T is not computed. */
606 /* > The number of rows in X. */
612 /* > The number of rows in X11. 0 <= P <= M. */
618 /* > The number of columns in X11 and X21. 0 <= Q <= M. */
621 /* > \param[in,out] X11 */
623 /* > X11 is REAL array, dimension (LDX11,Q) */
624 /* > On entry, part of the orthogonal matrix whose CSD is desired. */
627 /* > \param[in] LDX11 */
629 /* > LDX11 is INTEGER */
630 /* > The leading dimension of X11. LDX11 >= MAX(1,P). */
633 /* > \param[in,out] X21 */
635 /* > X21 is REAL array, dimension (LDX21,Q) */
636 /* > On entry, part of the orthogonal matrix whose CSD is desired. */
639 /* > \param[in] LDX21 */
641 /* > LDX21 is INTEGER */
642 /* > The leading dimension of X21. LDX21 >= MAX(1,M-P). */
645 /* > \param[out] THETA */
647 /* > THETA is REAL array, dimension (R), in which R = */
648 /* > MIN(P,M-P,Q,M-Q). */
649 /* > C = DIAG( COS(THETA(1)), ... , COS(THETA(R)) ) and */
650 /* > S = DIAG( SIN(THETA(1)), ... , SIN(THETA(R)) ). */
653 /* > \param[out] U1 */
655 /* > U1 is REAL array, dimension (P) */
656 /* > If JOBU1 = 'Y', U1 contains the P-by-P orthogonal matrix U1. */
659 /* > \param[in] LDU1 */
661 /* > LDU1 is INTEGER */
662 /* > The leading dimension of U1. If JOBU1 = 'Y', LDU1 >= */
666 /* > \param[out] U2 */
668 /* > U2 is REAL array, dimension (M-P) */
669 /* > If JOBU2 = 'Y', U2 contains the (M-P)-by-(M-P) orthogonal */
673 /* > \param[in] LDU2 */
675 /* > LDU2 is INTEGER */
676 /* > The leading dimension of U2. If JOBU2 = 'Y', LDU2 >= */
680 /* > \param[out] V1T */
682 /* > V1T is REAL array, dimension (Q) */
683 /* > If JOBV1T = 'Y', V1T contains the Q-by-Q matrix orthogonal */
684 /* > matrix V1**T. */
687 /* > \param[in] LDV1T */
689 /* > LDV1T is INTEGER */
690 /* > The leading dimension of V1T. If JOBV1T = 'Y', LDV1T >= */
694 /* > \param[out] WORK */
696 /* > WORK is REAL array, dimension (MAX(1,LWORK)) */
697 /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
698 /* > If INFO > 0 on exit, WORK(2:R) contains the values PHI(1), */
699 /* > ..., PHI(R-1) that, together with THETA(1), ..., THETA(R), */
700 /* > define the matrix in intermediate bidiagonal-block form */
701 /* > remaining after nonconvergence. INFO specifies the number */
702 /* > of nonzero PHI's. */
705 /* > \param[in] LWORK */
707 /* > LWORK is INTEGER */
708 /* > The dimension of the array WORK. */
710 /* > If LWORK = -1, then a workspace query is assumed; the routine */
711 /* > only calculates the optimal size of the WORK array, returns */
712 /* > this value as the first entry of the work array, and no error */
713 /* > message related to LWORK is issued by XERBLA. */
716 /* > \param[out] IWORK */
718 /* > IWORK is INTEGER array, dimension (M-MIN(P,M-P,Q,M-Q)) */
721 /* > \param[out] INFO */
723 /* > INFO is INTEGER */
724 /* > = 0: successful exit. */
725 /* > < 0: if INFO = -i, the i-th argument had an illegal value. */
726 /* > > 0: SBBCSD did not converge. See the description of WORK */
727 /* > above for details. */
730 /* > \par References: */
731 /* ================ */
733 /* > [1] Brian D. Sutton. Computing the complete CS decomposition. Numer. */
734 /* > Algorithms, 50(1):33-65, 2009. */
739 /* > \author Univ. of Tennessee */
740 /* > \author Univ. of California Berkeley */
741 /* > \author Univ. of Colorado Denver */
742 /* > \author NAG Ltd. */
744 /* > \date July 2012 */
746 /* > \ingroup realOTHERcomputational */
748 /* ===================================================================== */
749 /* Subroutine */ int sorcsd2by1_(char *jobu1, char *jobu2, char *jobv1t,
750 integer *m, integer *p, integer *q, real *x11, integer *ldx11, real *
751 x21, integer *ldx21, real *theta, real *u1, integer *ldu1, real *u2,
752 integer *ldu2, real *v1t, integer *ldv1t, real *work, integer *lwork,
753 integer *iwork, integer *info)
755 /* System generated locals */
756 integer u1_dim1, u1_offset, u2_dim1, u2_offset, v1t_dim1, v1t_offset,
757 x11_dim1, x11_offset, x21_dim1, x21_offset, i__1, i__2, i__3;
759 /* Local variables */
760 integer ib11d, ib11e, ib12d, ib12e, ib21d, ib21e, ib22d, ib22e, iphi,
761 lworkmin, lworkopt, i__, j, r__;
762 extern logical lsame_(char *, char *);
764 extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *,
766 integer lorglqmin, lorgqrmin, lorglqopt, itaup1, itaup2, itauq1,
768 logical wantu1, wantu2;
769 integer ibbcsd, lbbcsd;
770 extern /* Subroutine */ int sbbcsd_(char *, char *, char *, char *, char *
771 , integer *, integer *, integer *, real *, real *, real *,
772 integer *, real *, integer *, real *, integer *, real *, integer *
773 , real *, real *, real *, real *, real *, real *, real *, real *,
774 real *, integer *, integer *);
775 integer iorbdb, lorbdb;
776 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), slacpy_(
777 char *, integer *, integer *, real *, integer *, real *, integer *
780 extern /* Subroutine */ int slapmr_(logical *, integer *, integer *, real
781 *, integer *, integer *);
783 extern /* Subroutine */ int slapmt_(logical *, integer *, integer *, real
784 *, integer *, integer *);
785 integer iorgqr, lorgqr;
786 extern /* Subroutine */ int sorglq_(integer *, integer *, integer *, real
787 *, integer *, real *, real *, integer *, integer *), sorgqr_(
788 integer *, integer *, integer *, real *, integer *, real *, real *
789 , integer *, integer *);
791 extern /* Subroutine */ int sorbdb1_(integer *, integer *, integer *,
792 real *, integer *, real *, integer *, real *, real *, real *,
793 real *, real *, real *, integer *, integer *), sorbdb2_(integer *,
794 integer *, integer *, real *, integer *, real *, integer *, real
795 *, real *, real *, real *, real *, real *, integer *, integer *),
796 sorbdb3_(integer *, integer *, integer *, real *, integer *, real
797 *, integer *, real *, real *, real *, real *, real *, real *,
798 integer *, integer *), sorbdb4_(integer *, integer *, integer *,
799 real *, integer *, real *, integer *, real *, real *, real *,
800 real *, real *, real *, real *, integer *, integer *);
802 real dum1[1], dum2[1] /* was [1][1] */;
805 /* -- LAPACK computational routine (version 3.7.1) -- */
806 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
807 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
811 /* ===================================================================== */
814 /* Test input arguments */
816 /* Parameter adjustments */
818 x11_offset = 1 + x11_dim1 * 1;
821 x21_offset = 1 + x21_dim1 * 1;
825 u1_offset = 1 + u1_dim1 * 1;
828 u2_offset = 1 + u2_dim1 * 1;
831 v1t_offset = 1 + v1t_dim1 * 1;
838 wantu1 = lsame_(jobu1, "Y");
839 wantu2 = lsame_(jobu2, "Y");
840 wantv1t = lsame_(jobv1t, "Y");
841 lquery = *lwork == -1;
845 } else if (*p < 0 || *p > *m) {
847 } else if (*q < 0 || *q > *m) {
849 } else if (*ldx11 < f2cmax(1,*p)) {
851 } else /* if(complicated condition) */ {
853 i__1 = 1, i__2 = *m - *p;
854 if (*ldx21 < f2cmax(i__1,i__2)) {
856 } else if (wantu1 && *ldu1 < f2cmax(1,*p)) {
858 } else /* if(complicated condition) */ {
860 i__1 = 1, i__2 = *m - *p;
861 if (wantu2 && *ldu2 < f2cmax(i__1,i__2)) {
863 } else if (wantv1t && *ldv1t < f2cmax(1,*q)) {
870 i__1 = *p, i__2 = *m - *p, i__1 = f2cmin(i__1,i__2), i__1 = f2cmin(i__1,*q),
872 r__ = f2cmin(i__1,i__2);
874 /* Compute workspace */
877 /* |-------------------------------------------------------| */
878 /* | LWORKOPT (1) | */
879 /* |-------------------------------------------------------| */
880 /* | PHI (MAX(1,R-1)) | */
881 /* |-------------------------------------------------------| */
882 /* | TAUP1 (MAX(1,P)) | B11D (R) | */
883 /* | TAUP2 (MAX(1,M-P)) | B11E (R-1) | */
884 /* | TAUQ1 (MAX(1,Q)) | B12D (R) | */
885 /* |-----------------------------------------| B12E (R-1) | */
886 /* | SORBDB WORK | SORGQR WORK | SORGLQ WORK | B21D (R) | */
887 /* | | | | B21E (R-1) | */
888 /* | | | | B22D (R) | */
889 /* | | | | B22E (R-1) | */
890 /* | | | | SBBCSD WORK | */
891 /* |-------------------------------------------------------| */
896 i__1 = 1, i__2 = r__ - 1;
897 ib11d = iphi + f2cmax(i__1,i__2);
898 ib11e = ib11d + f2cmax(1,r__);
900 i__1 = 1, i__2 = r__ - 1;
901 ib12d = ib11e + f2cmax(i__1,i__2);
902 ib12e = ib12d + f2cmax(1,r__);
904 i__1 = 1, i__2 = r__ - 1;
905 ib21d = ib12e + f2cmax(i__1,i__2);
906 ib21e = ib21d + f2cmax(1,r__);
908 i__1 = 1, i__2 = r__ - 1;
909 ib22d = ib21e + f2cmax(i__1,i__2);
910 ib22e = ib22d + f2cmax(1,r__);
912 i__1 = 1, i__2 = r__ - 1;
913 ibbcsd = ib22e + f2cmax(i__1,i__2);
915 i__1 = 1, i__2 = r__ - 1;
916 itaup1 = iphi + f2cmax(i__1,i__2);
917 itaup2 = itaup1 + f2cmax(1,*p);
919 i__1 = 1, i__2 = *m - *p;
920 itauq1 = itaup2 + f2cmax(i__1,i__2);
921 iorbdb = itauq1 + f2cmax(1,*q);
922 iorgqr = itauq1 + f2cmax(1,*q);
923 iorglq = itauq1 + f2cmax(1,*q);
929 sorbdb1_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset],
930 ldx21, &theta[1], dum1, dum1, dum1, dum1, &work[1], &c_n1,
932 lorbdb = (integer) work[1];
933 if (wantu1 && *p > 0) {
934 sorgqr_(p, p, q, &u1[u1_offset], ldu1, dum1, &work[1], &c_n1,
936 lorgqrmin = f2cmax(lorgqrmin,*p);
938 i__1 = lorgqropt, i__2 = (integer) work[1];
939 lorgqropt = f2cmax(i__1,i__2);
941 if (wantu2 && *m - *p > 0) {
944 sorgqr_(&i__1, &i__2, q, &u2[u2_offset], ldu2, dum1, &work[1],
947 i__1 = lorgqrmin, i__2 = *m - *p;
948 lorgqrmin = f2cmax(i__1,i__2);
950 i__1 = lorgqropt, i__2 = (integer) work[1];
951 lorgqropt = f2cmax(i__1,i__2);
953 if (wantv1t && *q > 0) {
957 sorglq_(&i__1, &i__2, &i__3, &v1t[v1t_offset], ldv1t, dum1, &
958 work[1], &c_n1, &childinfo);
960 i__1 = lorglqmin, i__2 = *q - 1;
961 lorglqmin = f2cmax(i__1,i__2);
963 i__1 = lorglqopt, i__2 = (integer) work[1];
964 lorglqopt = f2cmax(i__1,i__2);
966 sbbcsd_(jobu1, jobu2, jobv1t, "N", "N", m, p, q, &theta[1], dum1,
967 &u1[u1_offset], ldu1, &u2[u2_offset], ldu2, &v1t[
968 v1t_offset], ldv1t, dum2, &c__1, dum1, dum1, dum1, dum1,
969 dum1, dum1, dum1, dum1, &work[1], &c_n1, &childinfo);
970 lbbcsd = (integer) work[1];
971 } else if (r__ == *p) {
972 sorbdb2_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset],
973 ldx21, &theta[1], dum1, dum1, dum1, dum1, &work[1], &c_n1,
975 lorbdb = (integer) work[1];
976 if (wantu1 && *p > 0) {
980 sorgqr_(&i__1, &i__2, &i__3, &u1[(u1_dim1 << 1) + 2], ldu1,
981 dum1, &work[1], &c_n1, &childinfo);
983 i__1 = lorgqrmin, i__2 = *p - 1;
984 lorgqrmin = f2cmax(i__1,i__2);
986 i__1 = lorgqropt, i__2 = (integer) work[1];
987 lorgqropt = f2cmax(i__1,i__2);
989 if (wantu2 && *m - *p > 0) {
992 sorgqr_(&i__1, &i__2, q, &u2[u2_offset], ldu2, dum1, &work[1],
995 i__1 = lorgqrmin, i__2 = *m - *p;
996 lorgqrmin = f2cmax(i__1,i__2);
998 i__1 = lorgqropt, i__2 = (integer) work[1];
999 lorgqropt = f2cmax(i__1,i__2);
1001 if (wantv1t && *q > 0) {
1002 sorglq_(q, q, &r__, &v1t[v1t_offset], ldv1t, dum1, &work[1], &
1004 lorglqmin = f2cmax(lorglqmin,*q);
1006 i__1 = lorglqopt, i__2 = (integer) work[1];
1007 lorglqopt = f2cmax(i__1,i__2);
1009 sbbcsd_(jobv1t, "N", jobu1, jobu2, "T", m, q, p, &theta[1], dum1,
1010 &v1t[v1t_offset], ldv1t, dum2, &c__1, &u1[u1_offset],
1011 ldu1, &u2[u2_offset], ldu2, dum1, dum1, dum1, dum1, dum1,
1012 dum1, dum1, dum1, &work[1], &c_n1, &childinfo);
1013 lbbcsd = (integer) work[1];
1014 } else if (r__ == *m - *p) {
1015 sorbdb3_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset],
1016 ldx21, &theta[1], dum1, dum1, dum1, dum1, &work[1], &c_n1,
1018 lorbdb = (integer) work[1];
1019 if (wantu1 && *p > 0) {
1020 sorgqr_(p, p, q, &u1[u1_offset], ldu1, dum1, &work[1], &c_n1,
1022 lorgqrmin = f2cmax(lorgqrmin,*p);
1024 i__1 = lorgqropt, i__2 = (integer) work[1];
1025 lorgqropt = f2cmax(i__1,i__2);
1027 if (wantu2 && *m - *p > 0) {
1031 sorgqr_(&i__1, &i__2, &i__3, &u2[(u2_dim1 << 1) + 2], ldu2,
1032 dum1, &work[1], &c_n1, &childinfo);
1034 i__1 = lorgqrmin, i__2 = *m - *p - 1;
1035 lorgqrmin = f2cmax(i__1,i__2);
1037 i__1 = lorgqropt, i__2 = (integer) work[1];
1038 lorgqropt = f2cmax(i__1,i__2);
1040 if (wantv1t && *q > 0) {
1041 sorglq_(q, q, &r__, &v1t[v1t_offset], ldv1t, dum1, &work[1], &
1043 lorglqmin = f2cmax(lorglqmin,*q);
1045 i__1 = lorglqopt, i__2 = (integer) work[1];
1046 lorglqopt = f2cmax(i__1,i__2);
1050 sbbcsd_("N", jobv1t, jobu2, jobu1, "T", m, &i__1, &i__2, &theta[1]
1051 , dum1, dum2, &c__1, &v1t[v1t_offset], ldv1t, &u2[
1052 u2_offset], ldu2, &u1[u1_offset], ldu1, dum1, dum1, dum1,
1053 dum1, dum1, dum1, dum1, dum1, &work[1], &c_n1, &childinfo);
1054 lbbcsd = (integer) work[1];
1056 sorbdb4_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset],
1057 ldx21, &theta[1], dum1, dum1, dum1, dum1, dum1, &work[1],
1059 lorbdb = *m + (integer) work[1];
1060 if (wantu1 && *p > 0) {
1062 sorgqr_(p, p, &i__1, &u1[u1_offset], ldu1, dum1, &work[1], &
1064 lorgqrmin = f2cmax(lorgqrmin,*p);
1066 i__1 = lorgqropt, i__2 = (integer) work[1];
1067 lorgqropt = f2cmax(i__1,i__2);
1069 if (wantu2 && *m - *p > 0) {
1073 sorgqr_(&i__1, &i__2, &i__3, &u2[u2_offset], ldu2, dum1, &
1074 work[1], &c_n1, &childinfo);
1076 i__1 = lorgqrmin, i__2 = *m - *p;
1077 lorgqrmin = f2cmax(i__1,i__2);
1079 i__1 = lorgqropt, i__2 = (integer) work[1];
1080 lorgqropt = f2cmax(i__1,i__2);
1082 if (wantv1t && *q > 0) {
1083 sorglq_(q, q, q, &v1t[v1t_offset], ldv1t, dum1, &work[1], &
1085 lorglqmin = f2cmax(lorglqmin,*q);
1087 i__1 = lorglqopt, i__2 = (integer) work[1];
1088 lorglqopt = f2cmax(i__1,i__2);
1092 sbbcsd_(jobu2, jobu1, "N", jobv1t, "N", m, &i__1, &i__2, &theta[1]
1093 , dum1, &u2[u2_offset], ldu2, &u1[u1_offset], ldu1, dum2,
1094 &c__1, &v1t[v1t_offset], ldv1t, dum1, dum1, dum1, dum1,
1095 dum1, dum1, dum1, dum1, &work[1], &c_n1, &childinfo);
1096 lbbcsd = (integer) work[1];
1099 i__1 = iorbdb + lorbdb - 1, i__2 = iorgqr + lorgqrmin - 1, i__1 = f2cmax(
1100 i__1,i__2), i__2 = iorglq + lorglqmin - 1, i__1 = f2cmax(i__1,
1101 i__2), i__2 = ibbcsd + lbbcsd - 1;
1102 lworkmin = f2cmax(i__1,i__2);
1104 i__1 = iorbdb + lorbdb - 1, i__2 = iorgqr + lorgqropt - 1, i__1 = f2cmax(
1105 i__1,i__2), i__2 = iorglq + lorglqopt - 1, i__1 = f2cmax(i__1,
1106 i__2), i__2 = ibbcsd + lbbcsd - 1;
1107 lworkopt = f2cmax(i__1,i__2);
1108 work[1] = (real) lworkopt;
1109 if (*lwork < lworkmin && ! lquery) {
1115 xerbla_("SORCSD2BY1", &i__1, (ftnlen)10);
1117 } else if (lquery) {
1120 lorgqr = *lwork - iorgqr + 1;
1121 lorglq = *lwork - iorglq + 1;
1123 /* Handle four cases separately: R = Q, R = P, R = M-P, and R = M-Q, */
1124 /* in which R = MIN(P,M-P,Q,M-Q) */
1130 /* Simultaneously bidiagonalize X11 and X21 */
1132 sorbdb1_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset], ldx21, &
1133 theta[1], &work[iphi], &work[itaup1], &work[itaup2], &work[
1134 itauq1], &work[iorbdb], &lorbdb, &childinfo);
1136 /* Accumulate Householder reflectors */
1138 if (wantu1 && *p > 0) {
1139 slacpy_("L", p, q, &x11[x11_offset], ldx11, &u1[u1_offset], ldu1);
1140 sorgqr_(p, p, q, &u1[u1_offset], ldu1, &work[itaup1], &work[
1141 iorgqr], &lorgqr, &childinfo);
1143 if (wantu2 && *m - *p > 0) {
1145 slacpy_("L", &i__1, q, &x21[x21_offset], ldx21, &u2[u2_offset],
1149 sorgqr_(&i__1, &i__2, q, &u2[u2_offset], ldu2, &work[itaup2], &
1150 work[iorgqr], &lorgqr, &childinfo);
1152 if (wantv1t && *q > 0) {
1153 v1t[v1t_dim1 + 1] = 1.f;
1155 for (j = 2; j <= i__1; ++j) {
1156 v1t[j * v1t_dim1 + 1] = 0.f;
1157 v1t[j + v1t_dim1] = 0.f;
1161 slacpy_("U", &i__1, &i__2, &x21[(x21_dim1 << 1) + 1], ldx21, &v1t[
1162 (v1t_dim1 << 1) + 2], ldv1t);
1166 sorglq_(&i__1, &i__2, &i__3, &v1t[(v1t_dim1 << 1) + 2], ldv1t, &
1167 work[itauq1], &work[iorglq], &lorglq, &childinfo);
1170 /* Simultaneously diagonalize X11 and X21. */
1172 sbbcsd_(jobu1, jobu2, jobv1t, "N", "N", m, p, q, &theta[1], &work[
1173 iphi], &u1[u1_offset], ldu1, &u2[u2_offset], ldu2, &v1t[
1174 v1t_offset], ldv1t, dum2, &c__1, &work[ib11d], &work[ib11e], &
1175 work[ib12d], &work[ib12e], &work[ib21d], &work[ib21e], &work[
1176 ib22d], &work[ib22e], &work[ibbcsd], &lbbcsd, &childinfo);
1178 /* Permute rows and columns to place zero submatrices in */
1179 /* preferred positions */
1181 if (*q > 0 && wantu2) {
1183 for (i__ = 1; i__ <= i__1; ++i__) {
1184 iwork[i__] = *m - *p - *q + i__;
1187 for (i__ = *q + 1; i__ <= i__1; ++i__) {
1188 iwork[i__] = i__ - *q;
1192 slapmt_(&c_false, &i__1, &i__2, &u2[u2_offset], ldu2, &iwork[1]);
1194 } else if (r__ == *p) {
1198 /* Simultaneously bidiagonalize X11 and X21 */
1200 sorbdb2_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset], ldx21, &
1201 theta[1], &work[iphi], &work[itaup1], &work[itaup2], &work[
1202 itauq1], &work[iorbdb], &lorbdb, &childinfo);
1204 /* Accumulate Householder reflectors */
1206 if (wantu1 && *p > 0) {
1207 u1[u1_dim1 + 1] = 1.f;
1209 for (j = 2; j <= i__1; ++j) {
1210 u1[j * u1_dim1 + 1] = 0.f;
1211 u1[j + u1_dim1] = 0.f;
1215 slacpy_("L", &i__1, &i__2, &x11[x11_dim1 + 2], ldx11, &u1[(
1216 u1_dim1 << 1) + 2], ldu1);
1220 sorgqr_(&i__1, &i__2, &i__3, &u1[(u1_dim1 << 1) + 2], ldu1, &work[
1221 itaup1], &work[iorgqr], &lorgqr, &childinfo);
1223 if (wantu2 && *m - *p > 0) {
1225 slacpy_("L", &i__1, q, &x21[x21_offset], ldx21, &u2[u2_offset],
1229 sorgqr_(&i__1, &i__2, q, &u2[u2_offset], ldu2, &work[itaup2], &
1230 work[iorgqr], &lorgqr, &childinfo);
1232 if (wantv1t && *q > 0) {
1233 slacpy_("U", p, q, &x11[x11_offset], ldx11, &v1t[v1t_offset],
1235 sorglq_(q, q, &r__, &v1t[v1t_offset], ldv1t, &work[itauq1], &work[
1236 iorglq], &lorglq, &childinfo);
1239 /* Simultaneously diagonalize X11 and X21. */
1241 sbbcsd_(jobv1t, "N", jobu1, jobu2, "T", m, q, p, &theta[1], &work[
1242 iphi], &v1t[v1t_offset], ldv1t, dum1, &c__1, &u1[u1_offset],
1243 ldu1, &u2[u2_offset], ldu2, &work[ib11d], &work[ib11e], &work[
1244 ib12d], &work[ib12e], &work[ib21d], &work[ib21e], &work[ib22d]
1245 , &work[ib22e], &work[ibbcsd], &lbbcsd, &childinfo);
1247 /* Permute rows and columns to place identity submatrices in */
1248 /* preferred positions */
1250 if (*q > 0 && wantu2) {
1252 for (i__ = 1; i__ <= i__1; ++i__) {
1253 iwork[i__] = *m - *p - *q + i__;
1256 for (i__ = *q + 1; i__ <= i__1; ++i__) {
1257 iwork[i__] = i__ - *q;
1261 slapmt_(&c_false, &i__1, &i__2, &u2[u2_offset], ldu2, &iwork[1]);
1263 } else if (r__ == *m - *p) {
1265 /* Case 3: R = M-P */
1267 /* Simultaneously bidiagonalize X11 and X21 */
1269 sorbdb3_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset], ldx21, &
1270 theta[1], &work[iphi], &work[itaup1], &work[itaup2], &work[
1271 itauq1], &work[iorbdb], &lorbdb, &childinfo);
1273 /* Accumulate Householder reflectors */
1275 if (wantu1 && *p > 0) {
1276 slacpy_("L", p, q, &x11[x11_offset], ldx11, &u1[u1_offset], ldu1);
1277 sorgqr_(p, p, q, &u1[u1_offset], ldu1, &work[itaup1], &work[
1278 iorgqr], &lorgqr, &childinfo);
1280 if (wantu2 && *m - *p > 0) {
1281 u2[u2_dim1 + 1] = 1.f;
1283 for (j = 2; j <= i__1; ++j) {
1284 u2[j * u2_dim1 + 1] = 0.f;
1285 u2[j + u2_dim1] = 0.f;
1289 slacpy_("L", &i__1, &i__2, &x21[x21_dim1 + 2], ldx21, &u2[(
1290 u2_dim1 << 1) + 2], ldu2);
1294 sorgqr_(&i__1, &i__2, &i__3, &u2[(u2_dim1 << 1) + 2], ldu2, &work[
1295 itaup2], &work[iorgqr], &lorgqr, &childinfo);
1297 if (wantv1t && *q > 0) {
1299 slacpy_("U", &i__1, q, &x21[x21_offset], ldx21, &v1t[v1t_offset],
1301 sorglq_(q, q, &r__, &v1t[v1t_offset], ldv1t, &work[itauq1], &work[
1302 iorglq], &lorglq, &childinfo);
1305 /* Simultaneously diagonalize X11 and X21. */
1309 sbbcsd_("N", jobv1t, jobu2, jobu1, "T", m, &i__1, &i__2, &theta[1], &
1310 work[iphi], dum1, &c__1, &v1t[v1t_offset], ldv1t, &u2[
1311 u2_offset], ldu2, &u1[u1_offset], ldu1, &work[ib11d], &work[
1312 ib11e], &work[ib12d], &work[ib12e], &work[ib21d], &work[ib21e]
1313 , &work[ib22d], &work[ib22e], &work[ibbcsd], &lbbcsd, &
1316 /* Permute rows and columns to place identity submatrices in */
1317 /* preferred positions */
1321 for (i__ = 1; i__ <= i__1; ++i__) {
1322 iwork[i__] = *q - r__ + i__;
1325 for (i__ = r__ + 1; i__ <= i__1; ++i__) {
1326 iwork[i__] = i__ - r__;
1329 slapmt_(&c_false, p, q, &u1[u1_offset], ldu1, &iwork[1]);
1332 slapmr_(&c_false, q, q, &v1t[v1t_offset], ldv1t, &iwork[1]);
1337 /* Case 4: R = M-Q */
1339 /* Simultaneously bidiagonalize X11 and X21 */
1342 sorbdb4_(m, p, q, &x11[x11_offset], ldx11, &x21[x21_offset], ldx21, &
1343 theta[1], &work[iphi], &work[itaup1], &work[itaup2], &work[
1344 itauq1], &work[iorbdb], &work[iorbdb + *m], &i__1, &childinfo)
1347 /* Accumulate Householder reflectors */
1349 if (wantu1 && *p > 0) {
1350 scopy_(p, &work[iorbdb], &c__1, &u1[u1_offset], &c__1);
1352 for (j = 2; j <= i__1; ++j) {
1353 u1[j * u1_dim1 + 1] = 0.f;
1357 slacpy_("L", &i__1, &i__2, &x11[x11_dim1 + 2], ldx11, &u1[(
1358 u1_dim1 << 1) + 2], ldu1);
1360 sorgqr_(p, p, &i__1, &u1[u1_offset], ldu1, &work[itaup1], &work[
1361 iorgqr], &lorgqr, &childinfo);
1363 if (wantu2 && *m - *p > 0) {
1365 scopy_(&i__1, &work[iorbdb + *p], &c__1, &u2[u2_offset], &c__1);
1367 for (j = 2; j <= i__1; ++j) {
1368 u2[j * u2_dim1 + 1] = 0.f;
1372 slacpy_("L", &i__1, &i__2, &x21[x21_dim1 + 2], ldx21, &u2[(
1373 u2_dim1 << 1) + 2], ldu2);
1377 sorgqr_(&i__1, &i__2, &i__3, &u2[u2_offset], ldu2, &work[itaup2],
1378 &work[iorgqr], &lorgqr, &childinfo);
1380 if (wantv1t && *q > 0) {
1382 slacpy_("U", &i__1, q, &x21[x21_offset], ldx21, &v1t[v1t_offset],
1384 i__1 = *p - (*m - *q);
1385 i__2 = *q - (*m - *q);
1386 slacpy_("U", &i__1, &i__2, &x11[*m - *q + 1 + (*m - *q + 1) *
1387 x11_dim1], ldx11, &v1t[*m - *q + 1 + (*m - *q + 1) *
1391 slacpy_("U", &i__1, &i__2, &x21[*m - *q + 1 + (*p + 1) * x21_dim1]
1392 , ldx21, &v1t[*p + 1 + (*p + 1) * v1t_dim1], ldv1t);
1393 sorglq_(q, q, q, &v1t[v1t_offset], ldv1t, &work[itauq1], &work[
1394 iorglq], &lorglq, &childinfo);
1397 /* Simultaneously diagonalize X11 and X21. */
1401 sbbcsd_(jobu2, jobu1, "N", jobv1t, "N", m, &i__1, &i__2, &theta[1], &
1402 work[iphi], &u2[u2_offset], ldu2, &u1[u1_offset], ldu1, dum1,
1403 &c__1, &v1t[v1t_offset], ldv1t, &work[ib11d], &work[ib11e], &
1404 work[ib12d], &work[ib12e], &work[ib21d], &work[ib21e], &work[
1405 ib22d], &work[ib22e], &work[ibbcsd], &lbbcsd, &childinfo);
1407 /* Permute rows and columns to place identity submatrices in */
1408 /* preferred positions */
1412 for (i__ = 1; i__ <= i__1; ++i__) {
1413 iwork[i__] = *p - r__ + i__;
1416 for (i__ = r__ + 1; i__ <= i__1; ++i__) {
1417 iwork[i__] = i__ - r__;
1420 slapmt_(&c_false, p, p, &u1[u1_offset], ldu1, &iwork[1]);
1423 slapmr_(&c_false, p, q, &v1t[v1t_offset], ldv1t, &iwork[1]);
1430 /* End of SORCSD2BY1 */