LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
sgelq2.f
Go to the documentation of this file.
1*> \brief \b SGELQ2 computes the LQ factorization of a general rectangular matrix using an unblocked algorithm.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SGELQ2 + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgelq2.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgelq2.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgelq2.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SGELQ2( M, N, A, LDA, TAU, WORK, INFO )
20*
21* .. Scalar Arguments ..
22* INTEGER INFO, LDA, M, N
23* ..
24* .. Array Arguments ..
25* REAL A( LDA, * ), TAU( * ), WORK( * )
26* ..
27*
28*
29*> \par Purpose:
30* =============
31*>
32*> \verbatim
33*>
34*> SGELQ2 computes an LQ factorization of a real m-by-n matrix A:
35*>
36*> A = ( L 0 ) * Q
37*>
38*> where:
39*>
40*> Q is a n-by-n orthogonal matrix;
41*> L is a lower-triangular m-by-m matrix;
42*> 0 is a m-by-(n-m) zero matrix, if m < n.
43*>
44*> \endverbatim
45*
46* Arguments:
47* ==========
48*
49*> \param[in] M
50*> \verbatim
51*> M is INTEGER
52*> The number of rows of the matrix A. M >= 0.
53*> \endverbatim
54*>
55*> \param[in] N
56*> \verbatim
57*> N is INTEGER
58*> The number of columns of the matrix A. N >= 0.
59*> \endverbatim
60*>
61*> \param[in,out] A
62*> \verbatim
63*> A is REAL array, dimension (LDA,N)
64*> On entry, the m by n matrix A.
65*> On exit, the elements on and below the diagonal of the array
66*> contain the m by min(m,n) lower trapezoidal matrix L (L is
67*> lower triangular if m <= n); the elements above the diagonal,
68*> with the array TAU, represent the orthogonal matrix Q as a
69*> product of elementary reflectors (see Further Details).
70*> \endverbatim
71*>
72*> \param[in] LDA
73*> \verbatim
74*> LDA is INTEGER
75*> The leading dimension of the array A. LDA >= max(1,M).
76*> \endverbatim
77*>
78*> \param[out] TAU
79*> \verbatim
80*> TAU is REAL array, dimension (min(M,N))
81*> The scalar factors of the elementary reflectors (see Further
82*> Details).
83*> \endverbatim
84*>
85*> \param[out] WORK
86*> \verbatim
87*> WORK is REAL array, dimension (M)
88*> \endverbatim
89*>
90*> \param[out] INFO
91*> \verbatim
92*> INFO is INTEGER
93*> = 0: successful exit
94*> < 0: if INFO = -i, the i-th argument had an illegal value
95*> \endverbatim
96*
97* Authors:
98* ========
99*
100*> \author Univ. of Tennessee
101*> \author Univ. of California Berkeley
102*> \author Univ. of Colorado Denver
103*> \author NAG Ltd.
104*
105*> \ingroup gelq2
106*
107*> \par Further Details:
108* =====================
109*>
110*> \verbatim
111*>
112*> The matrix Q is represented as a product of elementary reflectors
113*>
114*> Q = H(k) . . . H(2) H(1), where k = min(m,n).
115*>
116*> Each H(i) has the form
117*>
118*> H(i) = I - tau * v * v**T
119*>
120*> where tau is a real scalar, and v is a real vector with
121*> v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n),
122*> and tau in TAU(i).
123*> \endverbatim
124*>
125* =====================================================================
126 SUBROUTINE sgelq2( M, N, A, LDA, TAU, WORK, INFO )
127*
128* -- LAPACK computational routine --
129* -- LAPACK is a software package provided by Univ. of Tennessee, --
130* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
131*
132* .. Scalar Arguments ..
133 INTEGER INFO, LDA, M, N
134* ..
135* .. Array Arguments ..
136 REAL A( LDA, * ), TAU( * ), WORK( * )
137* ..
138*
139* =====================================================================
140*
141* .. Local Scalars ..
142 INTEGER I, K
143* ..
144* .. External Subroutines ..
145 EXTERNAL slarf1f, slarfg, xerbla
146* ..
147* .. Intrinsic Functions ..
148 INTRINSIC max, min
149* ..
150* .. Executable Statements ..
151*
152* Test the input arguments
153*
154 info = 0
155 IF( m.LT.0 ) THEN
156 info = -1
157 ELSE IF( n.LT.0 ) THEN
158 info = -2
159 ELSE IF( lda.LT.max( 1, m ) ) THEN
160 info = -4
161 END IF
162 IF( info.NE.0 ) THEN
163 CALL xerbla( 'SGELQ2', -info )
164 RETURN
165 END IF
166*
167 k = min( m, n )
168*
169 DO 10 i = 1, k
170*
171* Generate elementary reflector H(i) to annihilate A(i,i+1:n)
172*
173 CALL slarfg( n-i+1, a( i, i ), a( i, min( i+1, n ) ), lda,
174 $ tau( i ) )
175 IF( i.LT.m ) THEN
176*
177* Apply H(i) to A(i+1:m,i:n) from the right
178*
179 CALL slarf1f( 'Right', m-i, n-i+1, a( i, i ), lda,
180 $ tau( i ), a( i+1, i ), lda, work )
181 END IF
182 10 CONTINUE
183 RETURN
184*
185* End of SGELQ2
186*
187 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgelq2(m, n, a, lda, tau, work, info)
SGELQ2 computes the LQ factorization of a general rectangular matrix using an unblocked algorithm.
Definition sgelq2.f:127
subroutine slarfg(n, alpha, x, incx, tau)
SLARFG generates an elementary reflector (Householder matrix).
Definition slarfg.f:104
subroutine slarf1f(side, m, n, v, incv, tau, c, ldc, work)
SLARF1F applies an elementary reflector to a general rectangular
Definition slarf1f.f:123