LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages

◆ sgeqpf()

subroutine sgeqpf ( integer m,
integer n,
real, dimension( lda, * ) a,
integer lda,
integer, dimension( * ) jpvt,
real, dimension( * ) tau,
real, dimension( * ) work,
integer info )

SGEQPF

Download SGEQPF + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!> !> This routine is deprecated and has been replaced by routine SGEQP3. !> !> SGEQPF computes a QR factorization with column pivoting of a !> real M-by-N matrix A: A*P = Q*R. !>
Parameters
[in]M
!> M is INTEGER !> The number of rows of the matrix A. M >= 0. !>
[in]N
!> N is INTEGER !> The number of columns of the matrix A. N >= 0 !>
[in,out]A
!> A is REAL array, dimension (LDA,N) !> On entry, the M-by-N matrix A. !> On exit, the upper triangle of the array contains the !> min(M,N)-by-N upper triangular matrix R; the elements !> below the diagonal, together with the array TAU, !> represent the orthogonal matrix Q as a product of !> min(m,n) elementary reflectors. !>
[in]LDA
!> LDA is INTEGER !> The leading dimension of the array A. LDA >= max(1,M). !>
[in,out]JPVT
!> JPVT is INTEGER array, dimension (N) !> On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted !> to the front of A*P (a leading column); if JPVT(i) = 0, !> the i-th column of A is a free column. !> On exit, if JPVT(i) = k, then the i-th column of A*P !> was the k-th column of A. !>
[out]TAU
!> TAU is REAL array, dimension (min(M,N)) !> The scalar factors of the elementary reflectors. !>
[out]WORK
!> WORK is REAL array, dimension (3*N) !>
[out]INFO
!> INFO is INTEGER !> = 0: successful exit !> < 0: if INFO = -i, the i-th argument had an illegal value !>
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
!> !> The matrix Q is represented as a product of elementary reflectors !> !> Q = H(1) H(2) . . . H(n) !> !> Each H(i) has the form !> !> H = I - tau * v * v**T !> !> where tau is a real scalar, and v is a real vector with !> v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i). !> !> The matrix P is represented in jpvt as follows: If !> jpvt(j) = i !> then the jth column of P is the ith canonical unit vector. !> !> Partial column norm updating strategy modified by !> Z. Drmac and Z. Bujanovic, Dept. of Mathematics, !> University of Zagreb, Croatia. !> -- April 2011 -- !> For more details see LAPACK Working Note 176. !>

Definition at line 139 of file sgeqpf.f.

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*
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
integer function isamax(n, sx, incx)
ISAMAX
Definition isamax.f:71
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
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
real(wp) function snrm2(n, x, incx)
SNRM2
Definition snrm2.f90:89
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
Here is the call graph for this function:
Here is the caller graph for this function: