3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CUNMQR + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cunmqr.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cunmqr.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cunmqr.f">
21 * SUBROUTINE CUNMQR( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,
24 * .. Scalar Arguments ..
25 * CHARACTER SIDE, TRANS
26 * INTEGER INFO, K, LDA, LDC, LWORK, M, N
28 * .. Array Arguments ..
29 * COMPLEX A( LDA, * ), C( LDC, * ), TAU( * ),
39 *> CUNMQR overwrites the general complex M-by-N matrix C with
41 *> SIDE = 'L' SIDE = 'R'
42 *> TRANS = 'N': Q * C C * Q
43 *> TRANS = 'C': Q**H * C C * Q**H
45 *> where Q is a complex unitary matrix defined as the product of k
46 *> elementary reflectors
48 *> Q = H(1) H(2) . . . H(k)
50 *> as returned by CGEQRF. Q is of order M if SIDE = 'L' and of order N
59 *> SIDE is CHARACTER*1
60 *> = 'L': apply Q or Q**H from the Left;
61 *> = 'R': apply Q or Q**H from the Right.
66 *> TRANS is CHARACTER*1
67 *> = 'N': No transpose, apply Q;
68 *> = 'C': Conjugate transpose, apply Q**H.
74 *> The number of rows of the matrix C. M >= 0.
80 *> The number of columns of the matrix C. N >= 0.
86 *> The number of elementary reflectors whose product defines
88 *> If SIDE = 'L', M >= K >= 0;
89 *> if SIDE = 'R', N >= K >= 0.
94 *> A is COMPLEX array, dimension (LDA,K)
95 *> The i-th column must contain the vector which defines the
96 *> elementary reflector H(i), for i = 1,2,...,k, as returned by
97 *> CGEQRF in the first k columns of its array argument A.
103 *> The leading dimension of the array A.
104 *> If SIDE = 'L', LDA >= max(1,M);
105 *> if SIDE = 'R', LDA >= max(1,N).
110 *> TAU is COMPLEX array, dimension (K)
111 *> TAU(i) must contain the scalar factor of the elementary
112 *> reflector H(i), as returned by CGEQRF.
117 *> C is COMPLEX array, dimension (LDC,N)
118 *> On entry, the M-by-N matrix C.
119 *> On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.
125 *> The leading dimension of the array C. LDC >= max(1,M).
130 *> WORK is COMPLEX array, dimension (MAX(1,LWORK))
131 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
137 *> The dimension of the array WORK.
138 *> If SIDE = 'L', LWORK >= max(1,N);
139 *> if SIDE = 'R', LWORK >= max(1,M).
140 *> For good performance, LWORK should generally be larger.
142 *> If LWORK = -1, then a workspace query is assumed; the routine
143 *> only calculates the optimal size of the WORK array, returns
144 *> this value as the first entry of the WORK array, and no error
145 *> message related to LWORK is issued by XERBLA.
151 *> = 0: successful exit
152 *> < 0: if INFO = -i, the i-th argument had an illegal value
158 *> \author Univ. of Tennessee
159 *> \author Univ. of California Berkeley
160 *> \author Univ. of Colorado Denver
163 *> \date November 2015
165 *> \ingroup complexOTHERcomputational
167 * =====================================================================
168 SUBROUTINE CUNMQR( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,
169 $ WORK, LWORK, INFO )
171 * -- LAPACK computational routine (version 3.6.0) --
172 * -- LAPACK is a software package provided by Univ. of Tennessee, --
173 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
176 * .. Scalar Arguments ..
177 CHARACTER SIDE, TRANS
178 INTEGER INFO, K, LDA, LDC, LWORK, M, N
180 * .. Array Arguments ..
181 COMPLEX A( LDA, * ), C( LDC, * ), TAU( * ),
185 * =====================================================================
188 INTEGER NBMAX, LDT, TSIZE
189 PARAMETER ( NBMAX = 64, LDT = NBMAX+1,
190 $ TSIZE = LDT*NBMAX )
192 * .. Local Scalars ..
193 LOGICAL LEFT, LQUERY, NOTRAN
194 INTEGER I, I1, I2, I3, IB, IC, IINFO, IWT, JC, LDWORK,
195 $ LWKOPT, MI, NB, NBMIN, NI, NQ, NW
197 * .. External Functions ..
200 EXTERNAL LSAME, ILAENV
202 * .. External Subroutines ..
203 EXTERNAL CLARFB, CLARFT, CUNM2R, XERBLA
205 * .. Intrinsic Functions ..
208 * .. Executable Statements ..
210 * Test the input arguments
213 LEFT = LSAME( SIDE, 'L' )
214 NOTRAN = LSAME( TRANS, 'N' )
215 LQUERY = ( LWORK.EQ.-1 )
217 * NQ is the order of Q and NW is the minimum dimension of WORK
226 IF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THEN
228 ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THEN
230 ELSE IF( M.LT.0 ) THEN
232 ELSE IF( N.LT.0 ) THEN
234 ELSE IF( K.LT.0 .OR. K.GT.NQ ) THEN
236 ELSE IF( LDA.LT.MAX( 1, NQ ) ) THEN
238 ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
240 ELSE IF( LWORK.LT.MAX( 1, NW ) .AND. .NOT.LQUERY ) THEN
246 * Compute the workspace requirements
248 NB = MIN( NBMAX, ILAENV( 1, 'CUNMQR', SIDE // TRANS, M, N, K,
250 LWKOPT = MAX( 1, NW )*NB + TSIZE
255 CALL XERBLA( 'CUNMQR', -INFO )
257 ELSE IF( LQUERY ) THEN
261 * Quick return if possible
263 IF( M.EQ.0 .OR. N.EQ.0 .OR. K.EQ.0 ) THEN
270 IF( NB.GT.1 .AND. NB.LT.K ) THEN
271 IF( LWORK.LT.NW*NB+TSIZE ) THEN
272 NB = (LWORK-TSIZE) / LDWORK
273 NBMIN = MAX( 2, ILAENV( 2, 'CUNMQR', SIDE // TRANS, M, N, K,
278 IF( NB.LT.NBMIN .OR. NB.GE.K ) THEN
282 CALL CUNM2R( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK,
289 IF( ( LEFT .AND. .NOT.NOTRAN ) .OR.
290 $ ( .NOT.LEFT .AND. NOTRAN ) ) THEN
295 I1 = ( ( K-1 ) / NB )*NB + 1
309 IB = MIN( NB, K-I+1 )
311 * Form the triangular factor of the block reflector
312 * H = H(i) H(i+1) . . . H(i+ib-1)
314 CALL CLARFT( 'Forward', 'Columnwise', NQ-I+1, IB, A( I, I ),
315 $ LDA, TAU( I ), WORK( IWT ), LDT )
318 * H or H**H is applied to C(i:m,1:n)
324 * H or H**H is applied to C(1:m,i:n)
332 CALL CLARFB( SIDE, TRANS, 'Forward', 'Columnwise', MI, NI,
333 $ IB, A( I, I ), LDA, WORK( IWT ), LDT,
334 $ C( IC, JC ), LDC, WORK, LDWORK )