3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CUNMRQ + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cunmrq.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cunmrq.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cunmrq.f">
21 * SUBROUTINE CUNMRQ( 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 *> CUNMRQ 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 H(2)**H . . . H(k)**H
50 *> as returned by CGERQF. 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': 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
95 *> (LDA,M) if SIDE = 'L',
96 *> (LDA,N) if SIDE = 'R'
97 *> The i-th row must contain the vector which defines the
98 *> elementary reflector H(i), for i = 1,2,...,k, as returned by
99 *> CGERQF in the last k rows of its array argument A.
105 *> The leading dimension of the array A. LDA >= max(1,K).
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 CGERQF.
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 CUNMRQ( 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
195 INTEGER I, I1, I2, I3, IB, IINFO, IWT, LDWORK, LWKOPT,
196 $ MI, NB, NBMIN, NI, NQ, NW
198 * .. External Functions ..
201 EXTERNAL LSAME, ILAENV
203 * .. External Subroutines ..
204 EXTERNAL CLARFB, CLARFT, CUNMR2, XERBLA
206 * .. Intrinsic Functions ..
209 * .. Executable Statements ..
211 * Test the input arguments
214 LEFT = LSAME( SIDE, 'L' )
215 NOTRAN = LSAME( TRANS, 'N' )
216 LQUERY = ( LWORK.EQ.-1 )
218 * NQ is the order of Q and NW is the minimum dimension of WORK
227 IF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THEN
229 ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THEN
231 ELSE IF( M.LT.0 ) THEN
233 ELSE IF( N.LT.0 ) THEN
235 ELSE IF( K.LT.0 .OR. K.GT.NQ ) THEN
237 ELSE IF( LDA.LT.MAX( 1, K ) ) THEN
239 ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
241 ELSE IF( LWORK.LT.NW .AND. .NOT.LQUERY ) THEN
247 * Compute the workspace requirements
249 IF( M.EQ.0 .OR. N.EQ.0 ) THEN
252 NB = MIN( NBMAX, ILAENV( 1, 'CUNMRQ', SIDE // TRANS, M, N,
254 LWKOPT = NW*NB + TSIZE
260 CALL XERBLA( 'CUNMRQ', -INFO )
262 ELSE IF( LQUERY ) THEN
266 * Quick return if possible
268 IF( M.EQ.0 .OR. N.EQ.0 ) THEN
274 IF( NB.GT.1 .AND. NB.LT.K ) THEN
275 IF( LWORK.LT.NW*NB+TSIZE ) THEN
276 NB = (LWORK-TSIZE) / LDWORK
277 NBMIN = MAX( 2, ILAENV( 2, 'CUNMRQ', SIDE // TRANS, M, N, K,
282 IF( NB.LT.NBMIN .OR. NB.GE.K ) THEN
286 CALL CUNMR2( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK,
293 IF( ( LEFT .AND. .NOT.NOTRAN ) .OR.
294 $ ( .NOT.LEFT .AND. NOTRAN ) ) THEN
299 I1 = ( ( K-1 ) / NB )*NB + 1
317 IB = MIN( NB, K-I+1 )
319 * Form the triangular factor of the block reflector
320 * H = H(i+ib-1) . . . H(i+1) H(i)
322 CALL CLARFT( 'Backward', 'Rowwise', NQ-K+I+IB-1, IB,
323 $ A( I, 1 ), LDA, TAU( I ), WORK( IWT ), LDT )
326 * H or H**H is applied to C(1:m-k+i+ib-1,1:n)
328 MI = M - K + I + IB - 1
331 * H or H**H is applied to C(1:m,1:n-k+i+ib-1)
333 NI = N - K + I + IB - 1
338 CALL CLARFB( SIDE, TRANST, 'Backward', 'Rowwise', MI, NI,
339 $ IB, A( I, 1 ), LDA, WORK( IWT ), LDT, C, LDC,