LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sgeqpf.f
Go to the documentation of this file.
1*> \brief \b SGEQPF
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SGEQPF + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgeqpf.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgeqpf.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgeqpf.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SGEQPF( M, N, A, LDA, JPVT, TAU, WORK, INFO )
20*
21* .. Scalar Arguments ..
22* INTEGER INFO, LDA, M, N
23* ..
24* .. Array Arguments ..
25* INTEGER JPVT( * )
26* REAL A( LDA, * ), TAU( * ), WORK( * )
27* ..
28*
29*
30*> \par Purpose:
31* =============
32*>
33*> \verbatim
34*>
35*> This routine is deprecated and has been replaced by routine SGEQP3.
36*>
37*> SGEQPF computes a QR factorization with column pivoting of a
38*> real M-by-N matrix A: A*P = Q*R.
39*> \endverbatim
40*
41* Arguments:
42* ==========
43*
44*> \param[in] M
45*> \verbatim
46*> M is INTEGER
47*> The number of rows of the matrix A. M >= 0.
48*> \endverbatim
49*>
50*> \param[in] N
51*> \verbatim
52*> N is INTEGER
53*> The number of columns of the matrix A. N >= 0
54*> \endverbatim
55*>
56*> \param[in,out] A
57*> \verbatim
58*> A is REAL array, dimension (LDA,N)
59*> On entry, the M-by-N matrix A.
60*> On exit, the upper triangle of the array contains the
61*> min(M,N)-by-N upper triangular matrix R; the elements
62*> below the diagonal, together with the array TAU,
63*> represent the orthogonal matrix Q as a product of
64*> min(m,n) elementary reflectors.
65*> \endverbatim
66*>
67*> \param[in] LDA
68*> \verbatim
69*> LDA is INTEGER
70*> The leading dimension of the array A. LDA >= max(1,M).
71*> \endverbatim
72*>
73*> \param[in,out] JPVT
74*> \verbatim
75*> JPVT is INTEGER array, dimension (N)
76*> On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted
77*> to the front of A*P (a leading column); if JPVT(i) = 0,
78*> the i-th column of A is a free column.
79*> On exit, if JPVT(i) = k, then the i-th column of A*P
80*> was the k-th column of A.
81*> \endverbatim
82*>
83*> \param[out] TAU
84*> \verbatim
85*> TAU is REAL array, dimension (min(M,N))
86*> The scalar factors of the elementary reflectors.
87*> \endverbatim
88*>
89*> \param[out] WORK
90*> \verbatim
91*> WORK is REAL array, dimension (3*N)
92*> \endverbatim
93*>
94*> \param[out] INFO
95*> \verbatim
96*> INFO is INTEGER
97*> = 0: successful exit
98*> < 0: if INFO = -i, the i-th argument had an illegal value
99*> \endverbatim
100*
101* Authors:
102* ========
103*
104*> \author Univ. of Tennessee
105*> \author Univ. of California Berkeley
106*> \author Univ. of Colorado Denver
107*> \author NAG Ltd.
108*
109*> \ingroup realGEcomputational
110*
111*> \par Further Details:
112* =====================
113*>
114*> \verbatim
115*>
116*> The matrix Q is represented as a product of elementary reflectors
117*>
118*> Q = H(1) H(2) . . . H(n)
119*>
120*> Each H(i) has the form
121*>
122*> H = I - tau * v * v**T
123*>
124*> where tau is a real scalar, and v is a real vector with
125*> v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i).
126*>
127*> The matrix P is represented in jpvt as follows: If
128*> jpvt(j) = i
129*> then the jth column of P is the ith canonical unit vector.
130*>
131*> Partial column norm updating strategy modified by
132*> Z. Drmac and Z. Bujanovic, Dept. of Mathematics,
133*> University of Zagreb, Croatia.
134*> -- April 2011 --
135*> For more details see LAPACK Working Note 176.
136*> \endverbatim
137*>
138* =====================================================================
139 SUBROUTINE sgeqpf( M, N, A, LDA, JPVT, TAU, WORK, INFO )
140*
141* -- LAPACK computational routine --
142* -- LAPACK is a software package provided by Univ. of Tennessee, --
143* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
144*
145* .. Scalar Arguments ..
146 INTEGER INFO, LDA, M, N
147* ..
148* .. Array Arguments ..
149 INTEGER JPVT( * )
150 REAL A( LDA, * ), TAU( * ), WORK( * )
151* ..
152*
153* =====================================================================
154*
155* .. Parameters ..
156 REAL ZERO, ONE
157 parameter( zero = 0.0e+0, one = 1.0e+0 )
158* ..
159* .. Local Scalars ..
160 INTEGER I, ITEMP, J, MA, MN, PVT
161 REAL AII, TEMP, TEMP2, TOL3Z
162* ..
163* .. External Subroutines ..
164 EXTERNAL sgeqr2, slarf, slarfg, sorm2r, sswap, xerbla
165* ..
166* .. Intrinsic Functions ..
167 INTRINSIC abs, max, min, sqrt
168* ..
169* .. External Functions ..
170 INTEGER ISAMAX
171 REAL SLAMCH, SNRM2
172 EXTERNAL isamax, slamch, snrm2
173* ..
174* .. Executable Statements ..
175*
176* Test the input arguments
177*
178 info = 0
179 IF( m.LT.0 ) THEN
180 info = -1
181 ELSE IF( n.LT.0 ) THEN
182 info = -2
183 ELSE IF( lda.LT.max( 1, m ) ) THEN
184 info = -4
185 END IF
186 IF( info.NE.0 ) THEN
187 CALL xerbla( 'SGEQPF', -info )
188 RETURN
189 END IF
190*
191 mn = min( m, n )
192 tol3z = sqrt(slamch('Epsilon'))
193*
194* Move initial columns up front
195*
196 itemp = 1
197 DO 10 i = 1, n
198 IF( jpvt( i ).NE.0 ) THEN
199 IF( i.NE.itemp ) THEN
200 CALL sswap( m, a( 1, i ), 1, a( 1, itemp ), 1 )
201 jpvt( i ) = jpvt( itemp )
202 jpvt( itemp ) = i
203 ELSE
204 jpvt( i ) = i
205 END IF
206 itemp = itemp + 1
207 ELSE
208 jpvt( i ) = i
209 END IF
210 10 CONTINUE
211 itemp = itemp - 1
212*
213* Compute the QR factorization and update remaining columns
214*
215 IF( itemp.GT.0 ) THEN
216 ma = min( itemp, m )
217 CALL sgeqr2( m, ma, a, lda, tau, work, info )
218 IF( ma.LT.n ) THEN
219 CALL sorm2r( 'Left', 'Transpose', m, n-ma, ma, a, lda,
220 $ tau, a( 1, ma+1 ), lda, work, info )
221 END IF
222 END IF
223*
224 IF( itemp.LT.mn ) THEN
225*
226* Initialize partial column norms. The first n elements of
227* work store the exact column norms.
228*
229 DO 20 i = itemp + 1, n
230 work( i ) = snrm2( m-itemp, a( itemp+1, i ), 1 )
231 work( n+i ) = work( i )
232 20 CONTINUE
233*
234* Compute factorization
235*
236 DO 40 i = itemp + 1, mn
237*
238* Determine ith pivot column and swap if necessary
239*
240 pvt = ( i-1 ) + isamax( n-i+1, work( i ), 1 )
241*
242 IF( pvt.NE.i ) THEN
243 CALL sswap( m, a( 1, pvt ), 1, a( 1, i ), 1 )
244 itemp = jpvt( pvt )
245 jpvt( pvt ) = jpvt( i )
246 jpvt( i ) = itemp
247 work( pvt ) = work( i )
248 work( n+pvt ) = work( n+i )
249 END IF
250*
251* Generate elementary reflector H(i)
252*
253 IF( i.LT.m ) THEN
254 CALL slarfg( m-i+1, a( i, i ), a( i+1, i ), 1,
255 $ tau( i ) )
256 ELSE
257 CALL slarfg( 1, a( m, m ), a( m, m ), 1, tau( m ) )
258 END IF
259*
260 IF( i.LT.n ) THEN
261*
262* Apply H(i) to A(i:m,i+1:n) from the left
263*
264 aii = a( i, i )
265 a( i, i ) = one
266 CALL slarf( 'LEFT', m-i+1, n-i, a( i, i ), 1,
267 $ tau( i ), a( i, i+1 ), lda, work( 2*n+1 ) )
268 a( i, i ) = aii
269 END IF
270*
271* Update partial column norms
272*
273 DO 30 j = i + 1, n
274 IF( work( j ).NE.zero ) THEN
275*
276* NOTE: The following 4 lines follow from the analysis in
277* Lapack Working Note 176.
278*
279 temp = abs( a( i, j ) ) / work( j )
280 temp = max( zero, ( one+temp )*( one-temp ) )
281 temp2 = temp*( work( j ) / work( n+j ) )**2
282 IF( temp2 .LE. tol3z ) THEN
283 IF( m-i.GT.0 ) THEN
284 work( j ) = snrm2( m-i, a( i+1, j ), 1 )
285 work( n+j ) = work( j )
286 ELSE
287 work( j ) = zero
288 work( n+j ) = zero
289 END IF
290 ELSE
291 work( j ) = work( j )*sqrt( temp )
292 END IF
293 END IF
294 30 CONTINUE
295*
296 40 CONTINUE
297 END IF
298 RETURN
299*
300* End of SGEQPF
301*
302 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgeqr2(m, n, a, lda, tau, work, info)
SGEQR2 computes the QR factorization of a general rectangular matrix using an unblocked algorithm.
Definition sgeqr2.f:128
subroutine slarf(side, m, n, v, incv, tau, c, ldc, work)
SLARF applies an elementary reflector to a general rectangular matrix.
Definition slarf.f:122
subroutine slarfg(n, alpha, x, incx, tau)
SLARFG generates an elementary reflector (Householder matrix).
Definition slarfg.f:104
subroutine sswap(n, sx, incx, sy, incy)
SSWAP
Definition sswap.f:82
subroutine sorm2r(side, trans, m, n, k, a, lda, tau, c, ldc, work, info)
SORM2R multiplies a general matrix by the orthogonal matrix from a QR factorization determined by sge...
Definition sorm2r.f:157
subroutine sgeqpf(m, n, a, lda, jpvt, tau, work, info)
SGEQPF
Definition sgeqpf.f:140