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