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