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