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