1 *> \brief \b SGEQRT2 computes a QR factorization of a general real or complex matrix using the compact WY representation of Q.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SGEQRT2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgeqrt2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgeqrt2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgeqrt2.f">
21 * SUBROUTINE SGEQRT2( M, N, A, LDA, T, LDT, INFO )
23 * .. Scalar Arguments ..
24 * INTEGER INFO, LDA, LDT, M, N
26 * .. Array Arguments ..
27 * REAL A( LDA, * ), T( LDT, * )
36 *> SGEQRT2 computes a QR factorization of a real M-by-N matrix A,
37 *> using the compact WY representation of Q.
46 *> The number of rows of the matrix A. M >= N.
52 *> The number of columns of the matrix A. N >= 0.
57 *> A is REAL array, dimension (LDA,N)
58 *> On entry, the real M-by-N matrix A. On exit, the elements on and
59 *> above the diagonal contain the N-by-N upper triangular matrix R; the
60 *> elements below the diagonal are the columns of V. See below for
67 *> The leading dimension of the array A. LDA >= max(1,M).
72 *> T is REAL array, dimension (LDT,N)
73 *> The N-by-N upper triangular factor of the block reflector.
74 *> The elements on and above the diagonal contain the block
75 *> reflector T; the elements below the diagonal are not used.
76 *> See below for further details.
82 *> The leading dimension of the array T. LDT >= max(1,N).
88 *> = 0: successful exit
89 *> < 0: if INFO = -i, the i-th argument had an illegal value
95 *> \author Univ. of Tennessee
96 *> \author Univ. of California Berkeley
97 *> \author Univ. of Colorado Denver
100 *> \date September 2012
102 *> \ingroup realGEcomputational
104 *> \par Further Details:
105 * =====================
109 *> The matrix V stores the elementary reflectors H(i) in the i-th column
110 *> below the diagonal. For example, if M=5 and N=3, the matrix V is
118 *> where the vi's represent the vectors which define H(i), which are returned
119 *> in the matrix A. The 1's along the diagonal of V are not stored in A. The
120 *> block reflector H is then given by
122 *> H = I - V * T * V**T
124 *> where V**T is the transpose of V.
127 * =====================================================================
128 SUBROUTINE SGEQRT2( M, N, A, LDA, T, LDT, INFO )
130 * -- LAPACK computational routine (version 3.4.2) --
131 * -- LAPACK is a software package provided by Univ. of Tennessee, --
132 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
135 * .. Scalar Arguments ..
136 INTEGER INFO, LDA, LDT, M, N
138 * .. Array Arguments ..
139 REAL A( LDA, * ), T( LDT, * )
142 * =====================================================================
146 PARAMETER( ONE = 1.0, ZERO = 0.0 )
148 * .. Local Scalars ..
152 * .. External Subroutines ..
153 EXTERNAL SLARFG, SGEMV, SGER, STRMV, XERBLA
155 * .. Executable Statements ..
157 * Test the input arguments
162 ELSE IF( N.LT.0 ) THEN
164 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
166 ELSE IF( LDT.LT.MAX( 1, N ) ) THEN
170 CALL XERBLA( 'SGEQRT2', -INFO )
178 * Generate elem. refl. H(i) to annihilate A(i+1:m,i), tau(I) -> T(I,1)
180 CALL SLARFG( M-I+1, A( I, I ), A( MIN( I+1, M ), I ), 1,
184 * Apply H(i) to A(I:M,I+1:N) from the left
189 * W(1:N-I) := A(I:M,I+1:N)^H * A(I:M,I) [W = T(:,N)]
191 CALL SGEMV( 'T',M-I+1, N-I, ONE, A( I, I+1 ), LDA,
192 $ A( I, I ), 1, ZERO, T( 1, N ), 1 )
194 * A(I:M,I+1:N) = A(I:m,I+1:N) + alpha*A(I:M,I)*W(1:N-1)^H
197 CALL SGER( M-I+1, N-I, ALPHA, A( I, I ), 1,
198 $ T( 1, N ), 1, A( I, I+1 ), LDA )
207 * T(1:I-1,I) := alpha * A(I:M,1:I-1)**T * A(I:M,I)
210 CALL SGEMV( 'T', M-I+1, I-1, ALPHA, A( I, 1 ), LDA,
211 $ A( I, I ), 1, ZERO, T( 1, I ), 1 )
214 * T(1:I-1,I) := T(1:I-1,1:I-1) * T(1:I-1,I)
216 CALL STRMV( 'U', 'N', 'N', I-1, T, LDT, T( 1, I ), 1 )
220 T( I, I ) = T( I, 1 )