1 *> \brief \b SORG2R generates all or part of the orthogonal matrix Q from a QR factorization determined by sgeqrf (unblocked algorithm).
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SORG2R + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sorg2r.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sorg2r.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sorg2r.f">
21 * SUBROUTINE SORG2R( M, N, K, A, LDA, TAU, WORK, INFO )
23 * .. Scalar Arguments ..
24 * INTEGER INFO, K, LDA, M, N
26 * .. Array Arguments ..
27 * REAL A( LDA, * ), TAU( * ), WORK( * )
36 *> SORG2R generates an m by n real matrix Q with orthonormal columns,
37 *> which is defined as the first n columns of a product of k elementary
38 *> reflectors of order m
40 *> Q = H(1) H(2) . . . H(k)
42 *> as returned by SGEQRF.
51 *> The number of rows of the matrix Q. M >= 0.
57 *> The number of columns of the matrix Q. M >= N >= 0.
63 *> The number of elementary reflectors whose product defines the
64 *> matrix Q. N >= K >= 0.
69 *> A is REAL array, dimension (LDA,N)
70 *> On entry, the i-th column must contain the vector which
71 *> defines the elementary reflector H(i), for i = 1,2,...,k, as
72 *> returned by SGEQRF in the first k columns of its array
74 *> On exit, the m-by-n matrix Q.
80 *> The first dimension of the array A. LDA >= max(1,M).
85 *> TAU is REAL array, dimension (K)
86 *> TAU(i) must contain the scalar factor of the elementary
87 *> reflector H(i), as returned by SGEQRF.
92 *> WORK is REAL array, dimension (N)
98 *> = 0: successful exit
99 *> < 0: if INFO = -i, the i-th argument has an illegal value
105 *> \author Univ. of Tennessee
106 *> \author Univ. of California Berkeley
107 *> \author Univ. of Colorado Denver
110 *> \date September 2012
112 *> \ingroup realOTHERcomputational
114 * =====================================================================
115 SUBROUTINE SORG2R( M, N, K, A, LDA, TAU, WORK, INFO )
117 * -- LAPACK computational routine (version 3.4.2) --
118 * -- LAPACK is a software package provided by Univ. of Tennessee, --
119 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
122 * .. Scalar Arguments ..
123 INTEGER INFO, K, LDA, M, N
125 * .. Array Arguments ..
126 REAL A( LDA, * ), TAU( * ), WORK( * )
129 * =====================================================================
133 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
135 * .. Local Scalars ..
138 * .. External Subroutines ..
139 EXTERNAL SLARF, SSCAL, XERBLA
141 * .. Intrinsic Functions ..
144 * .. Executable Statements ..
146 * Test the input arguments
151 ELSE IF( N.LT.0 .OR. N.GT.M ) THEN
153 ELSE IF( K.LT.0 .OR. K.GT.N ) THEN
155 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
159 CALL XERBLA( 'SORG2R', -INFO )
163 * Quick return if possible
168 * Initialise columns k+1:n to columns of the unit matrix
179 * Apply H(i) to A(i:m,i:n) from the left
183 CALL SLARF( 'Left', M-I+1, N-I, A( I, I ), 1, TAU( I ),
184 $ A( I, I+1 ), LDA, WORK )
187 $ CALL SSCAL( M-I, -TAU( I ), A( I+1, I ), 1 )
188 A( I, I ) = ONE - TAU( I )
190 * Set A(1:i-1,i) to zero