1 *> \brief \b CUNGR2 generates all or part of the unitary matrix Q from an RQ factorization determined by cgerqf (unblocked algorithm).
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CUNGR2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cungr2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cungr2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cungr2.f">
21 * SUBROUTINE CUNGR2( M, N, K, A, LDA, TAU, WORK, INFO )
23 * .. Scalar Arguments ..
24 * INTEGER INFO, K, LDA, M, N
26 * .. Array Arguments ..
27 * COMPLEX A( LDA, * ), TAU( * ), WORK( * )
36 *> CUNGR2 generates an m by n complex matrix Q with orthonormal rows,
37 *> which is defined as the last m rows of a product of k elementary
38 *> reflectors of order n
40 *> Q = H(1)**H H(2)**H . . . H(k)**H
42 *> as returned by CGERQF.
51 *> The number of rows of the matrix Q. M >= 0.
57 *> The number of columns of the matrix Q. N >= M.
63 *> The number of elementary reflectors whose product defines the
64 *> matrix Q. M >= K >= 0.
69 *> A is COMPLEX array, dimension (LDA,N)
70 *> On entry, the (m-k+i)-th row must contain the vector which
71 *> defines the elementary reflector H(i), for i = 1,2,...,k, as
72 *> returned by CGERQF in the last k rows of its array argument
74 *> On exit, the m-by-n matrix Q.
80 *> The first dimension of the array A. LDA >= max(1,M).
85 *> TAU is COMPLEX array, dimension (K)
86 *> TAU(i) must contain the scalar factor of the elementary
87 *> reflector H(i), as returned by CGERQF.
92 *> WORK is COMPLEX array, dimension (M)
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 complexOTHERcomputational
114 * =====================================================================
115 SUBROUTINE CUNGR2( 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 COMPLEX A( LDA, * ), TAU( * ), WORK( * )
129 * =====================================================================
133 PARAMETER ( ONE = ( 1.0E+0, 0.0E+0 ),
134 $ ZERO = ( 0.0E+0, 0.0E+0 ) )
136 * .. Local Scalars ..
139 * .. External Subroutines ..
140 EXTERNAL CLACGV, CLARF, CSCAL, XERBLA
142 * .. Intrinsic Functions ..
145 * .. Executable Statements ..
147 * Test the input arguments
152 ELSE IF( N.LT.M ) THEN
154 ELSE IF( K.LT.0 .OR. K.GT.M ) THEN
156 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
160 CALL XERBLA( 'CUNGR2', -INFO )
164 * Quick return if possible
171 * Initialise rows 1:m-k to rows of the unit matrix
177 IF( J.GT.N-M .AND. J.LE.N-K )
178 $ A( M-N+J, J ) = ONE
185 * Apply H(i)**H to A(1:m-k+i,1:n-k+i) from the right
187 CALL CLACGV( N-M+II-1, A( II, 1 ), LDA )
188 A( II, N-M+II ) = ONE
189 CALL CLARF( 'Right', II-1, N-M+II, A( II, 1 ), LDA,
190 $ CONJG( TAU( I ) ), A, LDA, WORK )
191 CALL CSCAL( N-M+II-1, -TAU( I ), A( II, 1 ), LDA )
192 CALL CLACGV( N-M+II-1, A( II, 1 ), LDA )
193 A( II, N-M+II ) = ONE - CONJG( TAU( I ) )
195 * Set A(m-k+i,n-k+i+1:n) to zero
197 DO 30 L = N - M + II + 1, N