LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
cggsvp.f
Go to the documentation of this file.
1*> \brief \b CGGSVP
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CGGSVP + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cggsvp.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cggsvp.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cggsvp.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CGGSVP( JOBU, JOBV, JOBQ, M, P, N, A, LDA, B, LDB,
20* TOLA, TOLB, K, L, U, LDU, V, LDV, Q, LDQ,
21* IWORK, RWORK, TAU, WORK, INFO )
22*
23* .. Scalar Arguments ..
24* CHARACTER JOBQ, JOBU, JOBV
25* INTEGER INFO, K, L, LDA, LDB, LDQ, LDU, LDV, M, N, P
26* REAL TOLA, TOLB
27* ..
28* .. Array Arguments ..
29* INTEGER IWORK( * )
30* REAL RWORK( * )
31* COMPLEX A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
32* $ TAU( * ), U( LDU, * ), V( LDV, * ), WORK( * )
33* ..
34*
35*
36*> \par Purpose:
37* =============
38*>
39*> \verbatim
40*>
41*> This routine is deprecated and has been replaced by routine CGGSVP3.
42*>
43*> CGGSVP computes unitary matrices U, V and Q such that
44*>
45*> N-K-L K L
46*> U**H*A*Q = K ( 0 A12 A13 ) if M-K-L >= 0;
47*> L ( 0 0 A23 )
48*> M-K-L ( 0 0 0 )
49*>
50*> N-K-L K L
51*> = K ( 0 A12 A13 ) if M-K-L < 0;
52*> M-K ( 0 0 A23 )
53*>
54*> N-K-L K L
55*> V**H*B*Q = L ( 0 0 B13 )
56*> P-L ( 0 0 0 )
57*>
58*> where the K-by-K matrix A12 and L-by-L matrix B13 are nonsingular
59*> upper triangular; A23 is L-by-L upper triangular if M-K-L >= 0,
60*> otherwise A23 is (M-K)-by-L upper trapezoidal. K+L = the effective
61*> numerical rank of the (M+P)-by-N matrix (A**H,B**H)**H.
62*>
63*> This decomposition is the preprocessing step for computing the
64*> Generalized Singular Value Decomposition (GSVD), see subroutine
65*> CGGSVD.
66*> \endverbatim
67*
68* Arguments:
69* ==========
70*
71*> \param[in] JOBU
72*> \verbatim
73*> JOBU is CHARACTER*1
74*> = 'U': Unitary matrix U is computed;
75*> = 'N': U is not computed.
76*> \endverbatim
77*>
78*> \param[in] JOBV
79*> \verbatim
80*> JOBV is CHARACTER*1
81*> = 'V': Unitary matrix V is computed;
82*> = 'N': V is not computed.
83*> \endverbatim
84*>
85*> \param[in] JOBQ
86*> \verbatim
87*> JOBQ is CHARACTER*1
88*> = 'Q': Unitary matrix Q is computed;
89*> = 'N': Q is not computed.
90*> \endverbatim
91*>
92*> \param[in] M
93*> \verbatim
94*> M is INTEGER
95*> The number of rows of the matrix A. M >= 0.
96*> \endverbatim
97*>
98*> \param[in] P
99*> \verbatim
100*> P is INTEGER
101*> The number of rows of the matrix B. P >= 0.
102*> \endverbatim
103*>
104*> \param[in] N
105*> \verbatim
106*> N is INTEGER
107*> The number of columns of the matrices A and B. N >= 0.
108*> \endverbatim
109*>
110*> \param[in,out] A
111*> \verbatim
112*> A is COMPLEX array, dimension (LDA,N)
113*> On entry, the M-by-N matrix A.
114*> On exit, A contains the triangular (or trapezoidal) matrix
115*> described in the Purpose section.
116*> \endverbatim
117*>
118*> \param[in] LDA
119*> \verbatim
120*> LDA is INTEGER
121*> The leading dimension of the array A. LDA >= max(1,M).
122*> \endverbatim
123*>
124*> \param[in,out] B
125*> \verbatim
126*> B is COMPLEX array, dimension (LDB,N)
127*> On entry, the P-by-N matrix B.
128*> On exit, B contains the triangular matrix described in
129*> the Purpose section.
130*> \endverbatim
131*>
132*> \param[in] LDB
133*> \verbatim
134*> LDB is INTEGER
135*> The leading dimension of the array B. LDB >= max(1,P).
136*> \endverbatim
137*>
138*> \param[in] TOLA
139*> \verbatim
140*> TOLA is REAL
141*> \endverbatim
142*>
143*> \param[in] TOLB
144*> \verbatim
145*> TOLB is REAL
146*>
147*> TOLA and TOLB are the thresholds to determine the effective
148*> numerical rank of matrix B and a subblock of A. Generally,
149*> they are set to
150*> TOLA = MAX(M,N)*norm(A)*MACHEPS,
151*> TOLB = MAX(P,N)*norm(B)*MACHEPS.
152*> The size of TOLA and TOLB may affect the size of backward
153*> errors of the decomposition.
154*> \endverbatim
155*>
156*> \param[out] K
157*> \verbatim
158*> K is INTEGER
159*> \endverbatim
160*>
161*> \param[out] L
162*> \verbatim
163*> L is INTEGER
164*>
165*> On exit, K and L specify the dimension of the subblocks
166*> described in Purpose section.
167*> K + L = effective numerical rank of (A**H,B**H)**H.
168*> \endverbatim
169*>
170*> \param[out] U
171*> \verbatim
172*> U is COMPLEX array, dimension (LDU,M)
173*> If JOBU = 'U', U contains the unitary matrix U.
174*> If JOBU = 'N', U is not referenced.
175*> \endverbatim
176*>
177*> \param[in] LDU
178*> \verbatim
179*> LDU is INTEGER
180*> The leading dimension of the array U. LDU >= max(1,M) if
181*> JOBU = 'U'; LDU >= 1 otherwise.
182*> \endverbatim
183*>
184*> \param[out] V
185*> \verbatim
186*> V is COMPLEX array, dimension (LDV,P)
187*> If JOBV = 'V', V contains the unitary matrix V.
188*> If JOBV = 'N', V is not referenced.
189*> \endverbatim
190*>
191*> \param[in] LDV
192*> \verbatim
193*> LDV is INTEGER
194*> The leading dimension of the array V. LDV >= max(1,P) if
195*> JOBV = 'V'; LDV >= 1 otherwise.
196*> \endverbatim
197*>
198*> \param[out] Q
199*> \verbatim
200*> Q is COMPLEX array, dimension (LDQ,N)
201*> If JOBQ = 'Q', Q contains the unitary matrix Q.
202*> If JOBQ = 'N', Q is not referenced.
203*> \endverbatim
204*>
205*> \param[in] LDQ
206*> \verbatim
207*> LDQ is INTEGER
208*> The leading dimension of the array Q. LDQ >= max(1,N) if
209*> JOBQ = 'Q'; LDQ >= 1 otherwise.
210*> \endverbatim
211*>
212*> \param[out] IWORK
213*> \verbatim
214*> IWORK is INTEGER array, dimension (N)
215*> \endverbatim
216*>
217*> \param[out] RWORK
218*> \verbatim
219*> RWORK is REAL array, dimension (2*N)
220*> \endverbatim
221*>
222*> \param[out] TAU
223*> \verbatim
224*> TAU is COMPLEX array, dimension (N)
225*> \endverbatim
226*>
227*> \param[out] WORK
228*> \verbatim
229*> WORK is COMPLEX array, dimension (max(3*N,M,P))
230*> \endverbatim
231*>
232*> \param[out] INFO
233*> \verbatim
234*> INFO is INTEGER
235*> = 0: successful exit
236*> < 0: if INFO = -i, the i-th argument had an illegal value.
237*> \endverbatim
238*
239* Authors:
240* ========
241*
242*> \author Univ. of Tennessee
243*> \author Univ. of California Berkeley
244*> \author Univ. of Colorado Denver
245*> \author NAG Ltd.
246*
247*> \ingroup ggsvp
248*
249*> \par Further Details:
250* =====================
251*>
252*> The subroutine uses LAPACK subroutine CGEQPF for the QR factorization
253*> with column pivoting to detect the effective numerical rank of the
254*> a matrix. It may be replaced by a better rank determination strategy.
255*>
256* =====================================================================
257 SUBROUTINE cggsvp( JOBU, JOBV, JOBQ, M, P, N, A, LDA, B, LDB,
258 $ TOLA, TOLB, K, L, U, LDU, V, LDV, Q, LDQ,
259 $ IWORK, RWORK, TAU, WORK, INFO )
260*
261* -- LAPACK computational routine --
262* -- LAPACK is a software package provided by Univ. of Tennessee, --
263* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
264*
265* .. Scalar Arguments ..
266 CHARACTER JOBQ, JOBU, JOBV
267 INTEGER INFO, K, L, LDA, LDB, LDQ, LDU, LDV, M, N, P
268 REAL TOLA, TOLB
269* ..
270* .. Array Arguments ..
271 INTEGER IWORK( * )
272 REAL RWORK( * )
273 COMPLEX A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
274 $ tau( * ), u( ldu, * ), v( ldv, * ), work( * )
275* ..
276*
277* =====================================================================
278*
279* .. Parameters ..
280 COMPLEX CZERO, CONE
281 PARAMETER ( CZERO = ( 0.0e+0, 0.0e+0 ),
282 $ cone = ( 1.0e+0, 0.0e+0 ) )
283* ..
284* .. Local Scalars ..
285 LOGICAL FORWRD, WANTQ, WANTU, WANTV
286 INTEGER I, J
287 COMPLEX T
288* ..
289* .. External Functions ..
290 LOGICAL LSAME
291 EXTERNAL LSAME
292* ..
293* .. External Subroutines ..
294 EXTERNAL cgeqpf, cgeqr2, cgerq2, clacpy, clapmt, claset,
296* ..
297* .. Intrinsic Functions ..
298 INTRINSIC abs, aimag, max, min, real
299* ..
300* .. Statement Functions ..
301 REAL CABS1
302* ..
303* .. Statement Function definitions ..
304 cabs1( t ) = abs( real( t ) ) + abs( aimag( t ) )
305* ..
306* .. Executable Statements ..
307*
308* Test the input parameters
309*
310 wantu = lsame( jobu, 'U' )
311 wantv = lsame( jobv, 'V' )
312 wantq = lsame( jobq, 'Q' )
313 forwrd = .true.
314*
315 info = 0
316 IF( .NOT.( wantu .OR. lsame( jobu, 'N' ) ) ) THEN
317 info = -1
318 ELSE IF( .NOT.( wantv .OR. lsame( jobv, 'N' ) ) ) THEN
319 info = -2
320 ELSE IF( .NOT.( wantq .OR. lsame( jobq, 'N' ) ) ) THEN
321 info = -3
322 ELSE IF( m.LT.0 ) THEN
323 info = -4
324 ELSE IF( p.LT.0 ) THEN
325 info = -5
326 ELSE IF( n.LT.0 ) THEN
327 info = -6
328 ELSE IF( lda.LT.max( 1, m ) ) THEN
329 info = -8
330 ELSE IF( ldb.LT.max( 1, p ) ) THEN
331 info = -10
332 ELSE IF( ldu.LT.1 .OR. ( wantu .AND. ldu.LT.m ) ) THEN
333 info = -16
334 ELSE IF( ldv.LT.1 .OR. ( wantv .AND. ldv.LT.p ) ) THEN
335 info = -18
336 ELSE IF( ldq.LT.1 .OR. ( wantq .AND. ldq.LT.n ) ) THEN
337 info = -20
338 END IF
339 IF( info.NE.0 ) THEN
340 CALL xerbla( 'CGGSVP', -info )
341 RETURN
342 END IF
343*
344* QR with column pivoting of B: B*P = V*( S11 S12 )
345* ( 0 0 )
346*
347 DO 10 i = 1, n
348 iwork( i ) = 0
349 10 CONTINUE
350 CALL cgeqpf( p, n, b, ldb, iwork, tau, work, rwork, info )
351*
352* Update A := A*P
353*
354 CALL clapmt( forwrd, m, n, a, lda, iwork )
355*
356* Determine the effective rank of matrix B.
357*
358 l = 0
359 DO 20 i = 1, min( p, n )
360 IF( cabs1( b( i, i ) ).GT.tolb )
361 $ l = l + 1
362 20 CONTINUE
363*
364 IF( wantv ) THEN
365*
366* Copy the details of V, and form V.
367*
368 CALL claset( 'Full', p, p, czero, czero, v, ldv )
369 IF( p.GT.1 )
370 $ CALL clacpy( 'Lower', p-1, n, b( 2, 1 ), ldb, v( 2, 1 ),
371 $ ldv )
372 CALL cung2r( p, p, min( p, n ), v, ldv, tau, work, info )
373 END IF
374*
375* Clean up B
376*
377 DO 40 j = 1, l - 1
378 DO 30 i = j + 1, l
379 b( i, j ) = czero
380 30 CONTINUE
381 40 CONTINUE
382 IF( p.GT.l )
383 $ CALL claset( 'Full', p-l, n, czero, czero, b( l+1, 1 ),
384 $ ldb )
385*
386 IF( wantq ) THEN
387*
388* Set Q = I and Update Q := Q*P
389*
390 CALL claset( 'Full', n, n, czero, cone, q, ldq )
391 CALL clapmt( forwrd, n, n, q, ldq, iwork )
392 END IF
393*
394 IF( p.GE.l .AND. n.NE.l ) THEN
395*
396* RQ factorization of ( S11 S12 ) = ( 0 S12 )*Z
397*
398 CALL cgerq2( l, n, b, ldb, tau, work, info )
399*
400* Update A := A*Z**H
401*
402 CALL cunmr2( 'Right', 'Conjugate transpose', m, n, l, b,
403 $ ldb, tau, a, lda, work, info )
404 IF( wantq ) THEN
405*
406* Update Q := Q*Z**H
407*
408 CALL cunmr2( 'Right', 'Conjugate transpose', n, n, l, b,
409 $ ldb, tau, q, ldq, work, info )
410 END IF
411*
412* Clean up B
413*
414 CALL claset( 'Full', l, n-l, czero, czero, b, ldb )
415 DO 60 j = n - l + 1, n
416 DO 50 i = j - n + l + 1, l
417 b( i, j ) = czero
418 50 CONTINUE
419 60 CONTINUE
420*
421 END IF
422*
423* Let N-L L
424* A = ( A11 A12 ) M,
425*
426* then the following does the complete QR decomposition of A11:
427*
428* A11 = U*( 0 T12 )*P1**H
429* ( 0 0 )
430*
431 DO 70 i = 1, n - l
432 iwork( i ) = 0
433 70 CONTINUE
434 CALL cgeqpf( m, n-l, a, lda, iwork, tau, work, rwork, info )
435*
436* Determine the effective rank of A11
437*
438 k = 0
439 DO 80 i = 1, min( m, n-l )
440 IF( cabs1( a( i, i ) ).GT.tola )
441 $ k = k + 1
442 80 CONTINUE
443*
444* Update A12 := U**H*A12, where A12 = A( 1:M, N-L+1:N )
445*
446 CALL cunm2r( 'Left', 'Conjugate transpose', m, l,
447 $ min( m, n-l ), a, lda, tau, a( 1, n-l+1 ), lda, work,
448 $ info )
449*
450 IF( wantu ) THEN
451*
452* Copy the details of U, and form U
453*
454 CALL claset( 'Full', m, m, czero, czero, u, ldu )
455 IF( m.GT.1 )
456 $ CALL clacpy( 'Lower', m-1, n-l, a( 2, 1 ), lda,
457 $ u( 2, 1 ), ldu )
458 CALL cung2r( m, m, min( m, n-l ), u, ldu, tau, work, info )
459 END IF
460*
461 IF( wantq ) THEN
462*
463* Update Q( 1:N, 1:N-L ) = Q( 1:N, 1:N-L )*P1
464*
465 CALL clapmt( forwrd, n, n-l, q, ldq, iwork )
466 END IF
467*
468* Clean up A: set the strictly lower triangular part of
469* A(1:K, 1:K) = 0, and A( K+1:M, 1:N-L ) = 0.
470*
471 DO 100 j = 1, k - 1
472 DO 90 i = j + 1, k
473 a( i, j ) = czero
474 90 CONTINUE
475 100 CONTINUE
476 IF( m.GT.k )
477 $ CALL claset( 'Full', m-k, n-l, czero, czero, a( k+1, 1 ),
478 $ lda )
479*
480 IF( n-l.GT.k ) THEN
481*
482* RQ factorization of ( T11 T12 ) = ( 0 T12 )*Z1
483*
484 CALL cgerq2( k, n-l, a, lda, tau, work, info )
485*
486 IF( wantq ) THEN
487*
488* Update Q( 1:N,1:N-L ) = Q( 1:N,1:N-L )*Z1**H
489*
490 CALL cunmr2( 'Right', 'Conjugate transpose', n, n-l, k,
491 $ a, lda, tau, q, ldq, work, info )
492 END IF
493*
494* Clean up A
495*
496 CALL claset( 'Full', k, n-l-k, czero, czero, a, lda )
497 DO 120 j = n - l - k + 1, n - l
498 DO 110 i = j - n + l + k + 1, k
499 a( i, j ) = czero
500 110 CONTINUE
501 120 CONTINUE
502*
503 END IF
504*
505 IF( m.GT.k ) THEN
506*
507* QR factorization of A( K+1:M,N-L+1:N )
508*
509 CALL cgeqr2( m-k, l, a( k+1, n-l+1 ), lda, tau, work, info )
510*
511 IF( wantu ) THEN
512*
513* Update U(:,K+1:M) := U(:,K+1:M)*U1
514*
515 CALL cunm2r( 'Right', 'No transpose', m, m-k,
516 $ min( m-k, l ), a( k+1, n-l+1 ), lda, tau,
517 $ u( 1, k+1 ), ldu, work, info )
518 END IF
519*
520* Clean up
521*
522 DO 140 j = n - l + 1, n
523 DO 130 i = j - n + k + l + 1, m
524 a( i, j ) = czero
525 130 CONTINUE
526 140 CONTINUE
527*
528 END IF
529*
530 RETURN
531*
532* End of CGGSVP
533*
534 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine cgeqpf(m, n, a, lda, jpvt, tau, work, rwork, info)
CGEQPF
Definition cgeqpf.f:146
subroutine cggsvp(jobu, jobv, jobq, m, p, n, a, lda, b, ldb, tola, tolb, k, l, u, ldu, v, ldv, q, ldq, iwork, rwork, tau, work, info)
CGGSVP
Definition cggsvp.f:260
subroutine cgeqr2(m, n, a, lda, tau, work, info)
CGEQR2 computes the QR factorization of a general rectangular matrix using an unblocked algorithm.
Definition cgeqr2.f:128
subroutine cgerq2(m, n, a, lda, tau, work, info)
CGERQ2 computes the RQ factorization of a general rectangular matrix using an unblocked algorithm.
Definition cgerq2.f:121
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 clapmt(forwrd, m, n, x, ldx, k)
CLAPMT performs a forward or backward permutation of the columns of a matrix.
Definition clapmt.f:102
subroutine claset(uplo, m, n, alpha, beta, a, lda)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition claset.f:104
subroutine cung2r(m, n, k, a, lda, tau, work, info)
CUNG2R
Definition cung2r.f:112
subroutine cunm2r(side, trans, m, n, k, a, lda, tau, c, ldc, work, info)
CUNM2R multiplies a general matrix by the unitary matrix from a QR factorization determined by cgeqrf...
Definition cunm2r.f:157
subroutine cunmr2(side, trans, m, n, k, a, lda, tau, c, ldc, work, info)
CUNMR2 multiplies a general matrix by the unitary matrix from a RQ factorization determined by cgerqf...
Definition cunmr2.f:157