LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
cuncsd.f
Go to the documentation of this file.
1*> \brief \b CUNCSD
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CUNCSD + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cuncsd.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cuncsd.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cuncsd.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* RECURSIVE SUBROUTINE CUNCSD( JOBU1, JOBU2, JOBV1T, JOBV2T, TRANS,
20* SIGNS, M, P, Q, X11, LDX11, X12,
21* LDX12, X21, LDX21, X22, LDX22, THETA,
22* U1, LDU1, U2, LDU2, V1T, LDV1T, V2T,
23* LDV2T, WORK, LWORK, RWORK, LRWORK,
24* IWORK, INFO )
25*
26* .. Scalar Arguments ..
27* CHARACTER JOBU1, JOBU2, JOBV1T, JOBV2T, SIGNS, TRANS
28* INTEGER INFO, LDU1, LDU2, LDV1T, LDV2T, LDX11, LDX12,
29* $ LDX21, LDX22, LRWORK, LWORK, M, P, Q
30* ..
31* .. Array Arguments ..
32* INTEGER IWORK( * )
33* REAL THETA( * )
34* REAL RWORK( * )
35* COMPLEX U1( LDU1, * ), U2( LDU2, * ), V1T( LDV1T, * ),
36* $ V2T( LDV2T, * ), WORK( * ), X11( LDX11, * ),
37* $ X12( LDX12, * ), X21( LDX21, * ), X22( LDX22,
38* $ * )
39* ..
40*
41*
42*> \par Purpose:
43* =============
44*>
45*> \verbatim
46*>
47*> CUNCSD computes the CS decomposition of an M-by-M partitioned
48*> unitary matrix X:
49*>
50*> [ I 0 0 | 0 0 0 ]
51*> [ 0 C 0 | 0 -S 0 ]
52*> [ X11 | X12 ] [ U1 | ] [ 0 0 0 | 0 0 -I ] [ V1 | ]**H
53*> X = [-----------] = [---------] [---------------------] [---------] .
54*> [ X21 | X22 ] [ | U2 ] [ 0 0 0 | I 0 0 ] [ | V2 ]
55*> [ 0 S 0 | 0 C 0 ]
56*> [ 0 0 I | 0 0 0 ]
57*>
58*> X11 is P-by-Q. The unitary matrices U1, U2, V1, and V2 are P-by-P,
59*> (M-P)-by-(M-P), Q-by-Q, and (M-Q)-by-(M-Q), respectively. C and S are
60*> R-by-R nonnegative diagonal matrices satisfying C^2 + S^2 = I, in
61*> which R = MIN(P,M-P,Q,M-Q).
62*> \endverbatim
63*
64* Arguments:
65* ==========
66*
67*> \param[in] JOBU1
68*> \verbatim
69*> JOBU1 is CHARACTER
70*> = 'Y': U1 is computed;
71*> otherwise: U1 is not computed.
72*> \endverbatim
73*>
74*> \param[in] JOBU2
75*> \verbatim
76*> JOBU2 is CHARACTER
77*> = 'Y': U2 is computed;
78*> otherwise: U2 is not computed.
79*> \endverbatim
80*>
81*> \param[in] JOBV1T
82*> \verbatim
83*> JOBV1T is CHARACTER
84*> = 'Y': V1T is computed;
85*> otherwise: V1T is not computed.
86*> \endverbatim
87*>
88*> \param[in] JOBV2T
89*> \verbatim
90*> JOBV2T is CHARACTER
91*> = 'Y': V2T is computed;
92*> otherwise: V2T is not computed.
93*> \endverbatim
94*>
95*> \param[in] TRANS
96*> \verbatim
97*> TRANS is CHARACTER
98*> = 'T': X, U1, U2, V1T, and V2T are stored in row-major
99*> order;
100*> otherwise: X, U1, U2, V1T, and V2T are stored in column-
101*> major order.
102*> \endverbatim
103*>
104*> \param[in] SIGNS
105*> \verbatim
106*> SIGNS is CHARACTER
107*> = 'O': The lower-left block is made nonpositive (the
108*> "other" convention);
109*> otherwise: The upper-right block is made nonpositive (the
110*> "default" convention).
111*> \endverbatim
112*>
113*> \param[in] M
114*> \verbatim
115*> M is INTEGER
116*> The number of rows and columns in X.
117*> \endverbatim
118*>
119*> \param[in] P
120*> \verbatim
121*> P is INTEGER
122*> The number of rows in X11 and X12. 0 <= P <= M.
123*> \endverbatim
124*>
125*> \param[in] Q
126*> \verbatim
127*> Q is INTEGER
128*> The number of columns in X11 and X21. 0 <= Q <= M.
129*> \endverbatim
130*>
131*> \param[in,out] X11
132*> \verbatim
133*> X11 is COMPLEX array, dimension (LDX11,Q)
134*> On entry, part of the unitary matrix whose CSD is desired.
135*> \endverbatim
136*>
137*> \param[in] LDX11
138*> \verbatim
139*> LDX11 is INTEGER
140*> The leading dimension of X11. LDX11 >= MAX(1,P).
141*> \endverbatim
142*>
143*> \param[in,out] X12
144*> \verbatim
145*> X12 is COMPLEX array, dimension (LDX12,M-Q)
146*> On entry, part of the unitary matrix whose CSD is desired.
147*> \endverbatim
148*>
149*> \param[in] LDX12
150*> \verbatim
151*> LDX12 is INTEGER
152*> The leading dimension of X12. LDX12 >= MAX(1,P).
153*> \endverbatim
154*>
155*> \param[in,out] X21
156*> \verbatim
157*> X21 is COMPLEX array, dimension (LDX21,Q)
158*> On entry, part of the unitary matrix whose CSD is desired.
159*> \endverbatim
160*>
161*> \param[in] LDX21
162*> \verbatim
163*> LDX21 is INTEGER
164*> The leading dimension of X11. LDX21 >= MAX(1,M-P).
165*> \endverbatim
166*>
167*> \param[in,out] X22
168*> \verbatim
169*> X22 is COMPLEX array, dimension (LDX22,M-Q)
170*> On entry, part of the unitary matrix whose CSD is desired.
171*> \endverbatim
172*>
173*> \param[in] LDX22
174*> \verbatim
175*> LDX22 is INTEGER
176*> The leading dimension of X11. LDX22 >= MAX(1,M-P).
177*> \endverbatim
178*>
179*> \param[out] THETA
180*> \verbatim
181*> THETA is REAL array, dimension (R), in which R =
182*> MIN(P,M-P,Q,M-Q).
183*> C = DIAG( COS(THETA(1)), ... , COS(THETA(R)) ) and
184*> S = DIAG( SIN(THETA(1)), ... , SIN(THETA(R)) ).
185*> \endverbatim
186*>
187*> \param[out] U1
188*> \verbatim
189*> U1 is COMPLEX array, dimension (LDU1,P)
190*> If JOBU1 = 'Y', U1 contains the P-by-P unitary matrix U1.
191*> \endverbatim
192*>
193*> \param[in] LDU1
194*> \verbatim
195*> LDU1 is INTEGER
196*> The leading dimension of U1. If JOBU1 = 'Y', LDU1 >=
197*> MAX(1,P).
198*> \endverbatim
199*>
200*> \param[out] U2
201*> \verbatim
202*> U2 is COMPLEX array, dimension (LDU2,M-P)
203*> If JOBU2 = 'Y', U2 contains the (M-P)-by-(M-P) unitary
204*> matrix U2.
205*> \endverbatim
206*>
207*> \param[in] LDU2
208*> \verbatim
209*> LDU2 is INTEGER
210*> The leading dimension of U2. If JOBU2 = 'Y', LDU2 >=
211*> MAX(1,M-P).
212*> \endverbatim
213*>
214*> \param[out] V1T
215*> \verbatim
216*> V1T is COMPLEX array, dimension (LDV1T,Q)
217*> If JOBV1T = 'Y', V1T contains the Q-by-Q matrix unitary
218*> matrix V1**H.
219*> \endverbatim
220*>
221*> \param[in] LDV1T
222*> \verbatim
223*> LDV1T is INTEGER
224*> The leading dimension of V1T. If JOBV1T = 'Y', LDV1T >=
225*> MAX(1,Q).
226*> \endverbatim
227*>
228*> \param[out] V2T
229*> \verbatim
230*> V2T is COMPLEX array, dimension (LDV2T,M-Q)
231*> If JOBV2T = 'Y', V2T contains the (M-Q)-by-(M-Q) unitary
232*> matrix V2**H.
233*> \endverbatim
234*>
235*> \param[in] LDV2T
236*> \verbatim
237*> LDV2T is INTEGER
238*> The leading dimension of V2T. If JOBV2T = 'Y', LDV2T >=
239*> MAX(1,M-Q).
240*> \endverbatim
241*>
242*> \param[out] WORK
243*> \verbatim
244*> WORK is COMPLEX array, dimension (MAX(1,LWORK))
245*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
246*> \endverbatim
247*>
248*> \param[in] LWORK
249*> \verbatim
250*> LWORK is INTEGER
251*> The dimension of the array WORK.
252*>
253*> If LWORK = -1, then a workspace query is assumed; the routine
254*> only calculates the optimal size of the WORK array, returns
255*> this value as the first entry of the work array, and no error
256*> message related to LWORK is issued by XERBLA.
257*> \endverbatim
258*>
259*> \param[out] RWORK
260*> \verbatim
261*> RWORK is REAL array, dimension MAX(1,LRWORK)
262*> On exit, if INFO = 0, RWORK(1) returns the optimal LRWORK.
263*> If INFO > 0 on exit, RWORK(2:R) contains the values PHI(1),
264*> ..., PHI(R-1) that, together with THETA(1), ..., THETA(R),
265*> define the matrix in intermediate bidiagonal-block form
266*> remaining after nonconvergence. INFO specifies the number
267*> of nonzero PHI's.
268*> \endverbatim
269*>
270*> \param[in] LRWORK
271*> \verbatim
272*> LRWORK is INTEGER
273*> The dimension of the array RWORK.
274*>
275*> If LRWORK = -1, then a workspace query is assumed; the routine
276*> only calculates the optimal size of the RWORK array, returns
277*> this value as the first entry of the work array, and no error
278*> message related to LRWORK is issued by XERBLA.
279*> \endverbatim
280*>
281*> \param[out] IWORK
282*> \verbatim
283*> IWORK is INTEGER array, dimension (M-MIN(P,M-P,Q,M-Q))
284*> \endverbatim
285*>
286*> \param[out] INFO
287*> \verbatim
288*> INFO is INTEGER
289*> = 0: successful exit.
290*> < 0: if INFO = -i, the i-th argument had an illegal value.
291*> > 0: CBBCSD did not converge. See the description of RWORK
292*> above for details.
293*> \endverbatim
294*
295*> \par References:
296* ================
297*>
298*> [1] Brian D. Sutton. Computing the complete CS decomposition. Numer.
299*> Algorithms, 50(1):33-65, 2009.
300*
301* Authors:
302* ========
303*
304*> \author Univ. of Tennessee
305*> \author Univ. of California Berkeley
306*> \author Univ. of Colorado Denver
307*> \author NAG Ltd.
308*
309*> \ingroup uncsd
310*
311* =====================================================================
312 RECURSIVE SUBROUTINE cuncsd( JOBU1, JOBU2, JOBV1T, JOBV2T,
313 $ TRANS,
314 $ SIGNS, M, P, Q, X11, LDX11, X12,
315 $ LDX12, X21, LDX21, X22, LDX22, THETA,
316 $ U1, LDU1, U2, LDU2, V1T, LDV1T, V2T,
317 $ LDV2T, WORK, LWORK, RWORK, LRWORK,
318 $ IWORK, INFO )
319*
320* -- LAPACK computational routine --
321* -- LAPACK is a software package provided by Univ. of Tennessee, --
322* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
323*
324* .. Scalar Arguments ..
325 CHARACTER jobu1, jobu2, jobv1t, jobv2t, signs, trans
326 INTEGER info, ldu1, ldu2, ldv1t, ldv2t, ldx11, ldx12,
327 $ ldx21, ldx22, lrwork, lwork, m, p, q
328* ..
329* .. Array Arguments ..
330 INTEGER iwork( * )
331 REAL theta( * )
332 REAL rwork( * )
333 COMPLEX u1( ldu1, * ), u2( ldu2, * ), v1t( ldv1t, * ),
334 $ v2t( ldv2t, * ), work( * ), x11( ldx11, * ),
335 $ x12( ldx12, * ), x21( ldx21, * ), x22( ldx22,
336 $ * )
337* ..
338*
339* ===================================================================
340*
341* .. Parameters ..
342 COMPLEX one, zero
343 PARAMETER ( one = (1.0e0,0.0e0),
344 $ zero = (0.0e0,0.0e0) )
345* ..
346* .. Local Scalars ..
347 CHARACTER transt, signst
348 INTEGER childinfo, i, ib11d, ib11e, ib12d, ib12e,
349 $ ib21d, ib21e, ib22d, ib22e, ibbcsd, iorbdb,
350 $ iorglq, iorgqr, iphi, itaup1, itaup2, itauq1,
351 $ itauq2, j, lbbcsdwork, lbbcsdworkmin,
352 $ lbbcsdworkopt, lorbdbwork, lorbdbworkmin,
353 $ lorbdbworkopt, lorglqwork, lorglqworkmin,
354 $ lorglqworkopt, lorgqrwork, lorgqrworkmin,
355 $ lorgqrworkopt, lworkmin, lworkopt, p1, q1
356 LOGICAL colmajor, defaultsigns, lquery, wantu1, wantu2,
357 $ wantv1t, wantv2t
358 INTEGER lrworkmin, lrworkopt
359 LOGICAL lrquery
360* ..
361* .. External Subroutines ..
362 EXTERNAL xerbla, cbbcsd, clacpy, clapmr,
363 $ clapmt,
365* ..
366* .. External Functions ..
367 LOGICAL lsame
368 REAL sroundup_lwork
369 EXTERNAL lsame, sroundup_lwork
370* ..
371* .. Intrinsic Functions
372 INTRINSIC int, max, min
373* ..
374* .. Executable Statements ..
375*
376* Test input arguments
377*
378 info = 0
379 wantu1 = lsame( jobu1, 'Y' )
380 wantu2 = lsame( jobu2, 'Y' )
381 wantv1t = lsame( jobv1t, 'Y' )
382 wantv2t = lsame( jobv2t, 'Y' )
383 colmajor = .NOT. lsame( trans, 'T' )
384 defaultsigns = .NOT. lsame( signs, 'O' )
385 lquery = lwork .EQ. -1
386 lrquery = lrwork .EQ. -1
387 IF( m .LT. 0 ) THEN
388 info = -7
389 ELSE IF( p .LT. 0 .OR. p .GT. m ) THEN
390 info = -8
391 ELSE IF( q .LT. 0 .OR. q .GT. m ) THEN
392 info = -9
393 ELSE IF ( colmajor .AND. ldx11 .LT. max( 1, p ) ) THEN
394 info = -11
395 ELSE IF (.NOT. colmajor .AND. ldx11 .LT. max( 1, q ) ) THEN
396 info = -11
397 ELSE IF (colmajor .AND. ldx12 .LT. max( 1, p ) ) THEN
398 info = -13
399 ELSE IF (.NOT. colmajor .AND. ldx12 .LT. max( 1, m-q ) ) THEN
400 info = -13
401 ELSE IF (colmajor .AND. ldx21 .LT. max( 1, m-p ) ) THEN
402 info = -15
403 ELSE IF (.NOT. colmajor .AND. ldx21 .LT. max( 1, q ) ) THEN
404 info = -15
405 ELSE IF (colmajor .AND. ldx22 .LT. max( 1, m-p ) ) THEN
406 info = -17
407 ELSE IF (.NOT. colmajor .AND. ldx22 .LT. max( 1, m-q ) ) THEN
408 info = -17
409 ELSE IF( wantu1 .AND. ldu1 .LT. p ) THEN
410 info = -20
411 ELSE IF( wantu2 .AND. ldu2 .LT. m-p ) THEN
412 info = -22
413 ELSE IF( wantv1t .AND. ldv1t .LT. q ) THEN
414 info = -24
415 ELSE IF( wantv2t .AND. ldv2t .LT. m-q ) THEN
416 info = -26
417 END IF
418*
419* Work with transpose if convenient
420*
421 IF( info .EQ. 0 .AND. min( p, m-p ) .LT. min( q, m-q ) ) THEN
422 IF( colmajor ) THEN
423 transt = 'T'
424 ELSE
425 transt = 'N'
426 END IF
427 IF( defaultsigns ) THEN
428 signst = 'O'
429 ELSE
430 signst = 'D'
431 END IF
432 CALL cuncsd( jobv1t, jobv2t, jobu1, jobu2, transt, signst,
433 $ m,
434 $ q, p, x11, ldx11, x21, ldx21, x12, ldx12, x22,
435 $ ldx22, theta, v1t, ldv1t, v2t, ldv2t, u1, ldu1,
436 $ u2, ldu2, work, lwork, rwork, lrwork, iwork,
437 $ info )
438 RETURN
439 END IF
440*
441* Work with permutation [ 0 I; I 0 ] * X * [ 0 I; I 0 ] if
442* convenient
443*
444 IF( info .EQ. 0 .AND. m-q .LT. q ) THEN
445 IF( defaultsigns ) THEN
446 signst = 'O'
447 ELSE
448 signst = 'D'
449 END IF
450 CALL cuncsd( jobu2, jobu1, jobv2t, jobv1t, trans, signst, m,
451 $ m-p, m-q, x22, ldx22, x21, ldx21, x12, ldx12, x11,
452 $ ldx11, theta, u2, ldu2, u1, ldu1, v2t, ldv2t, v1t,
453 $ ldv1t, work, lwork, rwork, lrwork, iwork, info )
454 RETURN
455 END IF
456*
457* Compute workspace
458*
459 IF( info .EQ. 0 ) THEN
460*
461* Real workspace
462*
463 iphi = 2
464 ib11d = iphi + max( 1, q - 1 )
465 ib11e = ib11d + max( 1, q )
466 ib12d = ib11e + max( 1, q - 1 )
467 ib12e = ib12d + max( 1, q )
468 ib21d = ib12e + max( 1, q - 1 )
469 ib21e = ib21d + max( 1, q )
470 ib22d = ib21e + max( 1, q - 1 )
471 ib22e = ib22d + max( 1, q )
472 ibbcsd = ib22e + max( 1, q - 1 )
473 CALL cbbcsd( jobu1, jobu2, jobv1t, jobv2t, trans, m, p, q,
474 $ theta, theta, u1, ldu1, u2, ldu2, v1t, ldv1t,
475 $ v2t, ldv2t, theta, theta, theta, theta, theta,
476 $ theta, theta, theta, rwork, -1, childinfo )
477 lbbcsdworkopt = int( rwork(1) )
478 lbbcsdworkmin = lbbcsdworkopt
479 lrworkopt = ibbcsd + lbbcsdworkopt - 1
480 lrworkmin = ibbcsd + lbbcsdworkmin - 1
481 rwork(1) = real( lrworkopt )
482*
483* Complex workspace
484*
485 itaup1 = 2
486 itaup2 = itaup1 + max( 1, p )
487 itauq1 = itaup2 + max( 1, m - p )
488 itauq2 = itauq1 + max( 1, q )
489 iorgqr = itauq2 + max( 1, m - q )
490 CALL cungqr( m-q, m-q, m-q, u1, max(1,m-q), u1, work, -1,
491 $ childinfo )
492 lorgqrworkopt = int( work(1) )
493 lorgqrworkmin = max( 1, m - q )
494 iorglq = itauq2 + max( 1, m - q )
495 CALL cunglq( m-q, m-q, m-q, u1, max(1,m-q), u1, work, -1,
496 $ childinfo )
497 lorglqworkopt = int( work(1) )
498 lorglqworkmin = max( 1, m - q )
499 iorbdb = itauq2 + max( 1, m - q )
500 CALL cunbdb( trans, signs, m, p, q, x11, ldx11, x12, ldx12,
501 $ x21, ldx21, x22, ldx22, theta, theta, u1, u2,
502 $ v1t, v2t, work, -1, childinfo )
503 lorbdbworkopt = int( work(1) )
504 lorbdbworkmin = lorbdbworkopt
505 lworkopt = max( iorgqr + lorgqrworkopt, iorglq + lorglqworkopt,
506 $ iorbdb + lorbdbworkopt ) - 1
507 lworkmin = max( iorgqr + lorgqrworkmin, iorglq + lorglqworkmin,
508 $ iorbdb + lorbdbworkmin ) - 1
509 lworkopt = max(lworkopt,lworkmin)
510 work(1) = sroundup_lwork(lworkopt)
511*
512 IF( lwork .LT. lworkmin
513 $ .AND. .NOT. ( lquery .OR. lrquery ) ) THEN
514 info = -22
515 ELSE IF( lrwork .LT. lrworkmin
516 $ .AND. .NOT. ( lquery .OR. lrquery ) ) THEN
517 info = -24
518 ELSE
519 lorgqrwork = lwork - iorgqr + 1
520 lorglqwork = lwork - iorglq + 1
521 lorbdbwork = lwork - iorbdb + 1
522 lbbcsdwork = lrwork - ibbcsd + 1
523 END IF
524 END IF
525*
526* Abort if any illegal arguments
527*
528 IF( info .NE. 0 ) THEN
529 CALL xerbla( 'CUNCSD', -info )
530 RETURN
531 ELSE IF( lquery .OR. lrquery ) THEN
532 RETURN
533 END IF
534*
535* Transform to bidiagonal block form
536*
537 CALL cunbdb( trans, signs, m, p, q, x11, ldx11, x12, ldx12,
538 $ x21,
539 $ ldx21, x22, ldx22, theta, rwork(iphi), work(itaup1),
540 $ work(itaup2), work(itauq1), work(itauq2),
541 $ work(iorbdb), lorbdbwork, childinfo )
542*
543* Accumulate Householder reflectors
544*
545 IF( colmajor ) THEN
546 IF( wantu1 .AND. p .GT. 0 ) THEN
547 CALL clacpy( 'L', p, q, x11, ldx11, u1, ldu1 )
548 CALL cungqr( p, p, q, u1, ldu1, work(itaup1),
549 $ work(iorgqr),
550 $ lorgqrwork, info)
551 END IF
552 IF( wantu2 .AND. m-p .GT. 0 ) THEN
553 CALL clacpy( 'L', m-p, q, x21, ldx21, u2, ldu2 )
554 CALL cungqr( m-p, m-p, q, u2, ldu2, work(itaup2),
555 $ work(iorgqr), lorgqrwork, info )
556 END IF
557 IF( wantv1t .AND. q .GT. 0 ) THEN
558 CALL clacpy( 'U', q-1, q-1, x11(1,2), ldx11, v1t(2,2),
559 $ ldv1t )
560 v1t(1, 1) = one
561 DO j = 2, q
562 v1t(1,j) = zero
563 v1t(j,1) = zero
564 END DO
565 CALL cunglq( q-1, q-1, q-1, v1t(2,2), ldv1t,
566 $ work(itauq1),
567 $ work(iorglq), lorglqwork, info )
568 END IF
569 IF( wantv2t .AND. m-q .GT. 0 ) THEN
570 CALL clacpy( 'U', p, m-q, x12, ldx12, v2t, ldv2t )
571 IF( m-p .GT. q ) THEN
572 CALL clacpy( 'U', m-p-q, m-p-q, x22(q+1,p+1), ldx22,
573 $ v2t(p+1,p+1), ldv2t )
574 END IF
575 IF( m .GT. q ) THEN
576 CALL cunglq( m-q, m-q, m-q, v2t, ldv2t, work(itauq2),
577 $ work(iorglq), lorglqwork, info )
578 END IF
579 END IF
580 ELSE
581 IF( wantu1 .AND. p .GT. 0 ) THEN
582 CALL clacpy( 'U', q, p, x11, ldx11, u1, ldu1 )
583 CALL cunglq( p, p, q, u1, ldu1, work(itaup1),
584 $ work(iorglq),
585 $ lorglqwork, info)
586 END IF
587 IF( wantu2 .AND. m-p .GT. 0 ) THEN
588 CALL clacpy( 'U', q, m-p, x21, ldx21, u2, ldu2 )
589 CALL cunglq( m-p, m-p, q, u2, ldu2, work(itaup2),
590 $ work(iorglq), lorglqwork, info )
591 END IF
592 IF( wantv1t .AND. q .GT. 0 ) THEN
593 CALL clacpy( 'L', q-1, q-1, x11(2,1), ldx11, v1t(2,2),
594 $ ldv1t )
595 v1t(1, 1) = one
596 DO j = 2, q
597 v1t(1,j) = zero
598 v1t(j,1) = zero
599 END DO
600 CALL cungqr( q-1, q-1, q-1, v1t(2,2), ldv1t,
601 $ work(itauq1),
602 $ work(iorgqr), lorgqrwork, info )
603 END IF
604 IF( wantv2t .AND. m-q .GT. 0 ) THEN
605 p1 = min( p+1, m )
606 q1 = min( q+1, m )
607 CALL clacpy( 'L', m-q, p, x12, ldx12, v2t, ldv2t )
608 IF ( m .GT. p+q ) THEN
609 CALL clacpy( 'L', m-p-q, m-p-q, x22(p1,q1), ldx22,
610 $ v2t(p+1,p+1), ldv2t )
611 END IF
612 CALL cungqr( m-q, m-q, m-q, v2t, ldv2t, work(itauq2),
613 $ work(iorgqr), lorgqrwork, info )
614 END IF
615 END IF
616*
617* Compute the CSD of the matrix in bidiagonal-block form
618*
619 CALL cbbcsd( jobu1, jobu2, jobv1t, jobv2t, trans, m, p, q,
620 $ theta,
621 $ rwork(iphi), u1, ldu1, u2, ldu2, v1t, ldv1t, v2t,
622 $ ldv2t, rwork(ib11d), rwork(ib11e), rwork(ib12d),
623 $ rwork(ib12e), rwork(ib21d), rwork(ib21e),
624 $ rwork(ib22d), rwork(ib22e), rwork(ibbcsd),
625 $ lbbcsdwork, info )
626*
627* Permute rows and columns to place identity submatrices in top-
628* left corner of (1,1)-block and/or bottom-right corner of (1,2)-
629* block and/or bottom-right corner of (2,1)-block and/or top-left
630* corner of (2,2)-block
631*
632 IF( q .GT. 0 .AND. wantu2 ) THEN
633 DO i = 1, q
634 iwork(i) = m - p - q + i
635 END DO
636 DO i = q + 1, m - p
637 iwork(i) = i - q
638 END DO
639 IF( colmajor ) THEN
640 CALL clapmt( .false., m-p, m-p, u2, ldu2, iwork )
641 ELSE
642 CALL clapmr( .false., m-p, m-p, u2, ldu2, iwork )
643 END IF
644 END IF
645 IF( m .GT. 0 .AND. wantv2t ) THEN
646 DO i = 1, p
647 iwork(i) = m - p - q + i
648 END DO
649 DO i = p + 1, m - q
650 iwork(i) = i - p
651 END DO
652 IF( .NOT. colmajor ) THEN
653 CALL clapmt( .false., m-q, m-q, v2t, ldv2t, iwork )
654 ELSE
655 CALL clapmr( .false., m-q, m-q, v2t, ldv2t, iwork )
656 END IF
657 END IF
658*
659 RETURN
660*
661* End CUNCSD
662*
663 END
664
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine cbbcsd(jobu1, jobu2, jobv1t, jobv2t, trans, m, p, q, theta, phi, u1, ldu1, u2, ldu2, v1t, ldv1t, v2t, ldv2t, b11d, b11e, b12d, b12e, b21d, b21e, b22d, b22e, rwork, lrwork, info)
CBBCSD
Definition cbbcsd.f:331
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
Definition clacpy.f:101
subroutine clapmr(forwrd, m, n, x, ldx, k)
CLAPMR rearranges rows of a matrix as specified by a permutation vector.
Definition clapmr.f:102
subroutine clapmt(forwrd, m, n, x, ldx, k)
CLAPMT performs a forward or backward permutation of the columns of a matrix.
Definition clapmt.f:102
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
real function sroundup_lwork(lwork)
SROUNDUP_LWORK
subroutine cunbdb(trans, signs, m, p, q, x11, ldx11, x12, ldx12, x21, ldx21, x22, ldx22, theta, phi, taup1, taup2, tauq1, tauq2, work, lwork, info)
CUNBDB
Definition cunbdb.f:286
recursive subroutine cuncsd(jobu1, jobu2, jobv1t, jobv2t, trans, signs, m, p, q, x11, ldx11, x12, ldx12, x21, ldx21, x22, ldx22, theta, u1, ldu1, u2, ldu2, v1t, ldv1t, v2t, ldv2t, work, lwork, rwork, lrwork, iwork, info)
CUNCSD
Definition cuncsd.f:319
subroutine cunglq(m, n, k, a, lda, tau, work, lwork, info)
CUNGLQ
Definition cunglq.f:125
subroutine cungqr(m, n, k, a, lda, tau, work, lwork, info)
CUNGQR
Definition cungqr.f:126