LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dorglq.f
Go to the documentation of this file.
1*> \brief \b DORGLQ
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DORGLQ + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dorglq.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dorglq.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dorglq.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DORGLQ( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
20*
21* .. Scalar Arguments ..
22* INTEGER INFO, K, LDA, LWORK, M, N
23* ..
24* .. Array Arguments ..
25* DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * )
26* ..
27*
28*
29*> \par Purpose:
30* =============
31*>
32*> \verbatim
33*>
34*> DORGLQ generates an M-by-N real matrix Q with orthonormal rows,
35*> which is defined as the first M rows of a product of K elementary
36*> reflectors of order N
37*>
38*> Q = H(k) . . . H(2) H(1)
39*>
40*> as returned by DGELQF.
41*> \endverbatim
42*
43* Arguments:
44* ==========
45*
46*> \param[in] M
47*> \verbatim
48*> M is INTEGER
49*> The number of rows of the matrix Q. M >= 0.
50*> \endverbatim
51*>
52*> \param[in] N
53*> \verbatim
54*> N is INTEGER
55*> The number of columns of the matrix Q. N >= M.
56*> \endverbatim
57*>
58*> \param[in] K
59*> \verbatim
60*> K is INTEGER
61*> The number of elementary reflectors whose product defines the
62*> matrix Q. M >= K >= 0.
63*> \endverbatim
64*>
65*> \param[in,out] A
66*> \verbatim
67*> A is DOUBLE PRECISION array, dimension (LDA,N)
68*> On entry, the i-th row must contain the vector which defines
69*> the elementary reflector H(i), for i = 1,2,...,k, as returned
70*> by DGELQF in the first k rows of its array argument A.
71*> On exit, the M-by-N matrix Q.
72*> \endverbatim
73*>
74*> \param[in] LDA
75*> \verbatim
76*> LDA is INTEGER
77*> The first dimension of the array A. LDA >= max(1,M).
78*> \endverbatim
79*>
80*> \param[in] TAU
81*> \verbatim
82*> TAU is DOUBLE PRECISION array, dimension (K)
83*> TAU(i) must contain the scalar factor of the elementary
84*> reflector H(i), as returned by DGELQF.
85*> \endverbatim
86*>
87*> \param[out] WORK
88*> \verbatim
89*> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
90*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
91*> \endverbatim
92*>
93*> \param[in] LWORK
94*> \verbatim
95*> LWORK is INTEGER
96*> The dimension of the array WORK. LWORK >= max(1,M).
97*> For optimum performance LWORK >= M*NB, where NB is
98*> the optimal blocksize.
99*>
100*> If LWORK = -1, then a workspace query is assumed; the routine
101*> only calculates the optimal size of the WORK array, returns
102*> this value as the first entry of the WORK array, and no error
103*> message related to LWORK is issued by XERBLA.
104*> \endverbatim
105*>
106*> \param[out] INFO
107*> \verbatim
108*> INFO is INTEGER
109*> = 0: successful exit
110*> < 0: if INFO = -i, the i-th argument has an illegal value
111*> \endverbatim
112*
113* Authors:
114* ========
115*
116*> \author Univ. of Tennessee
117*> \author Univ. of California Berkeley
118*> \author Univ. of Colorado Denver
119*> \author NAG Ltd.
120*
121*> \ingroup unglq
122*
123* =====================================================================
124 SUBROUTINE dorglq( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
125*
126* -- LAPACK computational routine --
127* -- LAPACK is a software package provided by Univ. of Tennessee, --
128* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
129*
130* .. Scalar Arguments ..
131 INTEGER INFO, K, LDA, LWORK, M, N
132* ..
133* .. Array Arguments ..
134 DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * )
135* ..
136*
137* =====================================================================
138*
139* .. Parameters ..
140 DOUBLE PRECISION ZERO
141 parameter( zero = 0.0d+0 )
142* ..
143* .. Local Scalars ..
144 LOGICAL LQUERY
145 INTEGER I, IB, IINFO, IWS, J, KI, KK, L, LDWORK,
146 $ LWKOPT, NB, NBMIN, NX
147* ..
148* .. External Subroutines ..
149 EXTERNAL dlarfb, dlarft, dorgl2, xerbla
150* ..
151* .. Intrinsic Functions ..
152 INTRINSIC max, min
153* ..
154* .. External Functions ..
155 INTEGER ILAENV
156 EXTERNAL ilaenv
157* ..
158* .. Executable Statements ..
159*
160* Test the input arguments
161*
162 info = 0
163 nb = ilaenv( 1, 'DORGLQ', ' ', m, n, k, -1 )
164 lwkopt = max( 1, m )*nb
165 work( 1 ) = lwkopt
166 lquery = ( lwork.EQ.-1 )
167 IF( m.LT.0 ) THEN
168 info = -1
169 ELSE IF( n.LT.m ) THEN
170 info = -2
171 ELSE IF( k.LT.0 .OR. k.GT.m ) THEN
172 info = -3
173 ELSE IF( lda.LT.max( 1, m ) ) THEN
174 info = -5
175 ELSE IF( lwork.LT.max( 1, m ) .AND. .NOT.lquery ) THEN
176 info = -8
177 END IF
178 IF( info.NE.0 ) THEN
179 CALL xerbla( 'DORGLQ', -info )
180 RETURN
181 ELSE IF( lquery ) THEN
182 RETURN
183 END IF
184*
185* Quick return if possible
186*
187 IF( m.LE.0 ) THEN
188 work( 1 ) = 1
189 RETURN
190 END IF
191*
192 nbmin = 2
193 nx = 0
194 iws = m
195 IF( nb.GT.1 .AND. nb.LT.k ) THEN
196*
197* Determine when to cross over from blocked to unblocked code.
198*
199 nx = max( 0, ilaenv( 3, 'DORGLQ', ' ', m, n, k, -1 ) )
200 IF( nx.LT.k ) THEN
201*
202* Determine if workspace is large enough for blocked code.
203*
204 ldwork = m
205 iws = ldwork*nb
206 IF( lwork.LT.iws ) THEN
207*
208* Not enough workspace to use optimal NB: reduce NB and
209* determine the minimum value of NB.
210*
211 nb = lwork / ldwork
212 nbmin = max( 2, ilaenv( 2, 'DORGLQ', ' ', m, n, k,
213 $ -1 ) )
214 END IF
215 END IF
216 END IF
217*
218 IF( nb.GE.nbmin .AND. nb.LT.k .AND. nx.LT.k ) THEN
219*
220* Use blocked code after the last block.
221* The first kk rows are handled by the block method.
222*
223 ki = ( ( k-nx-1 ) / nb )*nb
224 kk = min( k, ki+nb )
225*
226* Set A(kk+1:m,1:kk) to zero.
227*
228 DO 20 j = 1, kk
229 DO 10 i = kk + 1, m
230 a( i, j ) = zero
231 10 CONTINUE
232 20 CONTINUE
233 ELSE
234 kk = 0
235 END IF
236*
237* Use unblocked code for the last or only block.
238*
239 IF( kk.LT.m )
240 $ CALL dorgl2( m-kk, n-kk, k-kk, a( kk+1, kk+1 ), lda,
241 $ tau( kk+1 ), work, iinfo )
242*
243 IF( kk.GT.0 ) THEN
244*
245* Use blocked code
246*
247 DO 50 i = ki + 1, 1, -nb
248 ib = min( nb, k-i+1 )
249 IF( i+ib.LE.m ) THEN
250*
251* Form the triangular factor of the block reflector
252* H = H(i) H(i+1) . . . H(i+ib-1)
253*
254 CALL dlarft( 'Forward', 'Rowwise', n-i+1, ib, a( i,
255 $ i ),
256 $ lda, tau( i ), work, ldwork )
257*
258* Apply H**T to A(i+ib:m,i:n) from the right
259*
260 CALL dlarfb( 'Right', 'Transpose', 'Forward',
261 $ 'Rowwise',
262 $ m-i-ib+1, n-i+1, ib, a( i, i ), lda, work,
263 $ ldwork, a( i+ib, i ), lda, work( ib+1 ),
264 $ ldwork )
265 END IF
266*
267* Apply H**T to columns i:n of current block
268*
269 CALL dorgl2( ib, n-i+1, ib, a( i, i ), lda, tau( i ),
270 $ work,
271 $ iinfo )
272*
273* Set columns 1:i-1 of current block to zero
274*
275 DO 40 j = 1, i - 1
276 DO 30 l = i, i + ib - 1
277 a( l, j ) = zero
278 30 CONTINUE
279 40 CONTINUE
280 50 CONTINUE
281 END IF
282*
283 work( 1 ) = iws
284 RETURN
285*
286* End of DORGLQ
287*
288 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine dlarfb(side, trans, direct, storev, m, n, k, v, ldv, t, ldt, c, ldc, work, ldwork)
DLARFB applies a block reflector or its transpose to a general rectangular matrix.
Definition dlarfb.f:195
recursive subroutine dlarft(direct, storev, n, k, v, ldv, tau, t, ldt)
DLARFT forms the triangular factor T of a block reflector H = I - vtvH
Definition dlarft.f:162
subroutine dorgl2(m, n, k, a, lda, tau, work, info)
DORGL2
Definition dorgl2.f:111
subroutine dorglq(m, n, k, a, lda, tau, work, lwork, info)
DORGLQ
Definition dorglq.f:125