LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
sggqrf.f
Go to the documentation of this file.
1*> \brief \b SGGQRF
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SGGQRF + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sggqrf.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sggqrf.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sggqrf.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SGGQRF( 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* REAL A( LDA, * ), B( LDB, * ), TAUA( * ), TAUB( * ),
27* $ WORK( * )
28* ..
29*
30*
31*> \par Purpose:
32* =============
33*>
34*> \verbatim
35*>
36*> SGGQRF 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 orthogonal matrix, Z is a P-by-P orthogonal
42*> matrix, 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**T*(inv(T)*R)
60*>
61*> where inv(B) denotes the inverse of the matrix B, and Z**T denotes the
62*> transpose of the 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 REAL 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 orthogonal 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 REAL array, dimension (min(N,M))
107*> The scalar factors of the elementary reflectors which
108*> represent the orthogonal matrix Q (see Further Details).
109*> \endverbatim
110*>
111*> \param[in,out] B
112*> \verbatim
113*> B is REAL 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 orthogonal
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 REAL array, dimension (min(N,P))
133*> The scalar factors of the elementary reflectors which
134*> represent the orthogonal matrix Z (see Further Details).
135*> \endverbatim
136*>
137*> \param[out] WORK
138*> \verbatim
139*> WORK is REAL 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 SORMQR.
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**T
188*>
189*> where taua is a real scalar, and v is a real 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 SORGQR.
193*> To use Q to update another matrix, use LAPACK subroutine SORMQR.
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**T
202*>
203*> where taub is a real scalar, and v is a real 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 SORGRQ.
207*> To use Z to update another matrix, use LAPACK subroutine SORMRQ.
208*> \endverbatim
209*>
210* =====================================================================
211 SUBROUTINE sggqrf( 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 REAL 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 sgeqrf, sgerqf, sormqr, xerbla
234* ..
235* .. External Functions ..
236 INTEGER ILAENV
237 EXTERNAL ilaenv
238 REAL SROUNDUP_LWORK
239 EXTERNAL sroundup_lwork
240* ..
241* .. Intrinsic Functions ..
242 INTRINSIC int, max, min
243* ..
244* .. Executable Statements ..
245*
246* Test the input parameters
247*
248 info = 0
249 nb1 = ilaenv( 1, 'SGEQRF', ' ', n, m, -1, -1 )
250 nb2 = ilaenv( 1, 'SGERQF', ' ', n, p, -1, -1 )
251 nb3 = ilaenv( 1, 'SORMQR', ' ', n, m, p, -1 )
252 nb = max( nb1, nb2, nb3 )
253 lwkopt = max( 1, max( n, m, p )*nb )
254 work( 1 ) = sroundup_lwork( lwkopt )
255*
256 lquery = ( lwork.EQ.-1 )
257 IF( n.LT.0 ) THEN
258 info = -1
259 ELSE IF( m.LT.0 ) THEN
260 info = -2
261 ELSE IF( p.LT.0 ) THEN
262 info = -3
263 ELSE IF( lda.LT.max( 1, n ) ) THEN
264 info = -5
265 ELSE IF( ldb.LT.max( 1, n ) ) THEN
266 info = -8
267 ELSE IF( lwork.LT.max( 1, n, m, p ) .AND. .NOT.lquery ) THEN
268 info = -11
269 END IF
270 IF( info.NE.0 ) THEN
271 CALL xerbla( 'SGGQRF', -info )
272 RETURN
273 ELSE IF( lquery ) THEN
274 RETURN
275 END IF
276*
277* QR factorization of N-by-M matrix A: A = Q*R
278*
279 CALL sgeqrf( n, m, a, lda, taua, work, lwork, info )
280 lopt = int( work( 1 ) )
281*
282* Update B := Q**T*B.
283*
284 CALL sormqr( 'Left', 'Transpose', n, p, min( n, m ), a, lda,
285 $ taua,
286 $ b, ldb, work, lwork, info )
287 lopt = max( lopt, int( work( 1 ) ) )
288*
289* RQ factorization of N-by-P matrix B: B = T*Z.
290*
291 CALL sgerqf( n, p, b, ldb, taub, work, lwork, info )
292 lwkopt = max( lopt, int( work( 1 ) ) )
293*
294 work( 1 ) = sroundup_lwork( lwkopt )
295*
296 RETURN
297*
298* End of SGGQRF
299*
300 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgeqrf(m, n, a, lda, tau, work, lwork, info)
SGEQRF
Definition sgeqrf.f:144
subroutine sgerqf(m, n, a, lda, tau, work, lwork, info)
SGERQF
Definition sgerqf.f:137
subroutine sggqrf(n, m, p, a, lda, taua, b, ldb, taub, work, lwork, info)
SGGQRF
Definition sggqrf.f:213
subroutine sormqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
SORMQR
Definition sormqr.f:166