LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
cggrqf.f
Go to the documentation of this file.
1*> \brief \b CGGRQF
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CGGRQF + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cggrqf.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cggrqf.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cggrqf.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CGGRQF( M, P, N, A, LDA, TAUA, B, LDB, TAUB, WORK,
20* LWORK, INFO )
21*
22* .. Scalar Arguments ..
23* INTEGER INFO, LDA, LDB, LWORK, M, N, P
24* ..
25* .. Array Arguments ..
26* COMPLEX A( LDA, * ), B( LDB, * ), TAUA( * ), TAUB( * ),
27* $ WORK( * )
28* ..
29*
30*
31*> \par Purpose:
32* =============
33*>
34*> \verbatim
35*>
36*> CGGRQF computes a generalized RQ factorization of an M-by-N matrix A
37*> and a P-by-N matrix B:
38*>
39*> A = R*Q, B = Z*T*Q,
40*>
41*> where Q is an N-by-N unitary matrix, Z is a P-by-P unitary
42*> matrix, and R and T assume one of the forms:
43*>
44*> if M <= N, R = ( 0 R12 ) M, or if M > N, R = ( R11 ) M-N,
45*> N-M M ( R21 ) N
46*> N
47*>
48*> where R12 or R21 is upper triangular, and
49*>
50*> if P >= N, T = ( T11 ) N , or if P < N, T = ( T11 T12 ) P,
51*> ( 0 ) P-N P N-P
52*> N
53*>
54*> where T11 is upper triangular.
55*>
56*> In particular, if B is square and nonsingular, the GRQ factorization
57*> of A and B implicitly gives the RQ factorization of A*inv(B):
58*>
59*> A*inv(B) = (R*inv(T))*Z**H
60*>
61*> where inv(B) denotes the inverse of the matrix B, and Z**H denotes the
62*> conjugate transpose of the matrix Z.
63*> \endverbatim
64*
65* Arguments:
66* ==========
67*
68*> \param[in] M
69*> \verbatim
70*> M is INTEGER
71*> The number of rows of the matrix A. M >= 0.
72*> \endverbatim
73*>
74*> \param[in] P
75*> \verbatim
76*> P is INTEGER
77*> The number of rows of the matrix B. P >= 0.
78*> \endverbatim
79*>
80*> \param[in] N
81*> \verbatim
82*> N is INTEGER
83*> The number of columns of the matrices A and B. N >= 0.
84*> \endverbatim
85*>
86*> \param[in,out] A
87*> \verbatim
88*> A is COMPLEX array, dimension (LDA,N)
89*> On entry, the M-by-N matrix A.
90*> On exit, if M <= N, the upper triangle of the subarray
91*> A(1:M,N-M+1:N) contains the M-by-M upper triangular matrix R;
92*> if M > N, the elements on and above the (M-N)-th subdiagonal
93*> contain the M-by-N upper trapezoidal matrix R; the remaining
94*> elements, with the array TAUA, represent the unitary
95*> matrix Q as a product of elementary reflectors (see Further
96*> Details).
97*> \endverbatim
98*>
99*> \param[in] LDA
100*> \verbatim
101*> LDA is INTEGER
102*> The leading dimension of the array A. LDA >= max(1,M).
103*> \endverbatim
104*>
105*> \param[out] TAUA
106*> \verbatim
107*> TAUA is COMPLEX array, dimension (min(M,N))
108*> The scalar factors of the elementary reflectors which
109*> represent the unitary matrix Q (see Further Details).
110*> \endverbatim
111*>
112*> \param[in,out] B
113*> \verbatim
114*> B is COMPLEX array, dimension (LDB,N)
115*> On entry, the P-by-N matrix B.
116*> On exit, the elements on and above the diagonal of the array
117*> contain the min(P,N)-by-N upper trapezoidal matrix T (T is
118*> upper triangular if P >= N); the elements below the diagonal,
119*> with the array TAUB, represent the unitary matrix Z as a
120*> product of elementary reflectors (see Further Details).
121*> \endverbatim
122*>
123*> \param[in] LDB
124*> \verbatim
125*> LDB is INTEGER
126*> The leading dimension of the array B. LDB >= max(1,P).
127*> \endverbatim
128*>
129*> \param[out] TAUB
130*> \verbatim
131*> TAUB is COMPLEX array, dimension (min(P,N))
132*> The scalar factors of the elementary reflectors which
133*> represent the unitary matrix Z (see Further Details).
134*> \endverbatim
135*>
136*> \param[out] WORK
137*> \verbatim
138*> WORK is COMPLEX array, dimension (MAX(1,LWORK))
139*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
140*> \endverbatim
141*>
142*> \param[in] LWORK
143*> \verbatim
144*> LWORK is INTEGER
145*> The dimension of the array WORK. LWORK >= max(1,N,M,P).
146*> For optimum performance LWORK >= max(N,M,P)*max(NB1,NB2,NB3),
147*> where NB1 is the optimal blocksize for the RQ factorization
148*> of an M-by-N matrix, NB2 is the optimal blocksize for the
149*> QR factorization of a P-by-N matrix, and NB3 is the optimal
150*> blocksize for a call of CUNMRQ.
151*>
152*> If LWORK = -1, then a workspace query is assumed; the routine
153*> only calculates the optimal size of the WORK array, returns
154*> this value as the first entry of the WORK array, and no error
155*> message related to LWORK is issued by XERBLA.
156*> \endverbatim
157*>
158*> \param[out] INFO
159*> \verbatim
160*> INFO is INTEGER
161*> = 0: successful exit
162*> < 0: if INFO=-i, the i-th argument had an illegal value.
163*> \endverbatim
164*
165* Authors:
166* ========
167*
168*> \author Univ. of Tennessee
169*> \author Univ. of California Berkeley
170*> \author Univ. of Colorado Denver
171*> \author NAG Ltd.
172*
173*> \ingroup ggrqf
174*
175*> \par Further Details:
176* =====================
177*>
178*> \verbatim
179*>
180*> The matrix Q is represented as a product of elementary reflectors
181*>
182*> Q = H(1) H(2) . . . H(k), where k = min(m,n).
183*>
184*> Each H(i) has the form
185*>
186*> H(i) = I - taua * v * v**H
187*>
188*> where taua is a complex scalar, and v is a complex vector with
189*> v(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in
190*> A(m-k+i,1:n-k+i-1), and taua in TAUA(i).
191*> To form Q explicitly, use LAPACK subroutine CUNGRQ.
192*> To use Q to update another matrix, use LAPACK subroutine CUNMRQ.
193*>
194*> The matrix Z is represented as a product of elementary reflectors
195*>
196*> Z = H(1) H(2) . . . H(k), where k = min(p,n).
197*>
198*> Each H(i) has the form
199*>
200*> H(i) = I - taub * v * v**H
201*>
202*> where taub is a complex scalar, and v is a complex vector with
203*> v(1:i-1) = 0 and v(i) = 1; v(i+1:p) is stored on exit in B(i+1:p,i),
204*> and taub in TAUB(i).
205*> To form Z explicitly, use LAPACK subroutine CUNGQR.
206*> To use Z to update another matrix, use LAPACK subroutine CUNMQR.
207*> \endverbatim
208*>
209* =====================================================================
210 SUBROUTINE cggrqf( M, P, N, A, LDA, TAUA, B, LDB, TAUB, WORK,
211 $ LWORK, INFO )
212*
213* -- LAPACK computational routine --
214* -- LAPACK is a software package provided by Univ. of Tennessee, --
215* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
216*
217* .. Scalar Arguments ..
218 INTEGER INFO, LDA, LDB, LWORK, M, N, P
219* ..
220* .. Array Arguments ..
221 COMPLEX A( LDA, * ), B( LDB, * ), TAUA( * ), TAUB( * ),
222 $ work( * )
223* ..
224*
225* =====================================================================
226*
227* .. Local Scalars ..
228 LOGICAL LQUERY
229 INTEGER LOPT, LWKOPT, NB, NB1, NB2, NB3
230* ..
231* .. External Subroutines ..
232 EXTERNAL cgeqrf, cgerqf, cunmrq, xerbla
233* ..
234* .. External Functions ..
235 INTEGER ILAENV
236 REAL SROUNDUP_LWORK
237 EXTERNAL ilaenv, sroundup_lwork
238* ..
239* .. Intrinsic Functions ..
240 INTRINSIC int, max, min
241* ..
242* .. Executable Statements ..
243*
244* Test the input parameters
245*
246 info = 0
247 nb1 = ilaenv( 1, 'CGERQF', ' ', m, n, -1, -1 )
248 nb2 = ilaenv( 1, 'CGEQRF', ' ', p, n, -1, -1 )
249 nb3 = ilaenv( 1, 'CUNMRQ', ' ', m, n, p, -1 )
250 nb = max( nb1, nb2, nb3 )
251 lwkopt = max( 1, max( n, m, p )*nb )
252 work( 1 ) = sroundup_lwork( lwkopt )
253 lquery = ( lwork.EQ.-1 )
254 IF( m.LT.0 ) THEN
255 info = -1
256 ELSE IF( p.LT.0 ) THEN
257 info = -2
258 ELSE IF( n.LT.0 ) THEN
259 info = -3
260 ELSE IF( lda.LT.max( 1, m ) ) THEN
261 info = -5
262 ELSE IF( ldb.LT.max( 1, p ) ) THEN
263 info = -8
264 ELSE IF( lwork.LT.max( 1, m, p, n ) .AND. .NOT.lquery ) THEN
265 info = -11
266 END IF
267 IF( info.NE.0 ) THEN
268 CALL xerbla( 'CGGRQF', -info )
269 RETURN
270 ELSE IF( lquery ) THEN
271 RETURN
272 END IF
273*
274* RQ factorization of M-by-N matrix A: A = R*Q
275*
276 CALL cgerqf( m, n, a, lda, taua, work, lwork, info )
277 lopt = int( work( 1 ) )
278*
279* Update B := B*Q**H
280*
281 CALL cunmrq( 'Right', 'Conjugate Transpose', p, n, min( m, n ),
282 $ a( max( 1, m-n+1 ), 1 ), lda, taua, b, ldb, work,
283 $ lwork, info )
284 lopt = max( lopt, int( work( 1 ) ) )
285*
286* QR factorization of P-by-N matrix B: B = Z*T
287*
288 CALL cgeqrf( p, n, b, ldb, taub, work, lwork, info )
289 work( 1 ) = sroundup_lwork( max( lopt, int( work( 1 ) ) ) )
290*
291 RETURN
292*
293* End of CGGRQF
294*
295 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine cgeqrf(m, n, a, lda, tau, work, lwork, info)
CGEQRF
Definition cgeqrf.f:144
subroutine cgerqf(m, n, a, lda, tau, work, lwork, info)
CGERQF
Definition cgerqf.f:137
subroutine cggrqf(m, p, n, a, lda, taua, b, ldb, taub, work, lwork, info)
CGGRQF
Definition cggrqf.f:212
subroutine cunmrq(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
CUNMRQ
Definition cunmrq.f:166