158 SUBROUTINE cunm22( SIDE, TRANS, M, N, N1, N2, Q, LDQ, C, LDC,
159 $ WORK, LWORK, INFO )
168 CHARACTER SIDE, TRANS
169 INTEGER M, N, N1, N2, LDQ, LDC, LWORK, INFO
172 COMPLEX Q( LDQ, * ), C( LDC, * ), WORK( * )
179 parameter( one = ( 1.0e+0, 0.0e+0 ) )
182 LOGICAL LEFT, LQUERY, NOTRAN
183 INTEGER I, LDWORK, LEN, LWKOPT, NB, NQ, NW
193 INTRINSIC cmplx, max, min
200 left = lsame( side,
'L' )
201 notran = lsame( trans,
'N' )
202 lquery = ( lwork.EQ.-1 )
213 IF( n1.EQ.0 .OR. n2.EQ.0 ) nw = 1
214 IF( .NOT.left .AND. .NOT.lsame( side,
'R' ) )
THEN
216 ELSE IF( .NOT.lsame( trans,
'N' ) .AND.
217 $ .NOT.lsame( trans,
'C' ) )
220 ELSE IF( m.LT.0 )
THEN
222 ELSE IF( n.LT.0 )
THEN
224 ELSE IF( n1.LT.0 .OR. n1+n2.NE.nq )
THEN
226 ELSE IF( n2.LT.0 )
THEN
228 ELSE IF( ldq.LT.max( 1, nq ) )
THEN
230 ELSE IF( ldc.LT.max( 1, m ) )
THEN
232 ELSE IF( lwork.LT.nw .AND. .NOT.lquery )
THEN
238 work( 1 ) = cmplx( lwkopt )
242 CALL xerbla(
'CUNM22', -info )
244 ELSE IF( lquery )
THEN
250 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
258 CALL ctrmm( side,
'Upper', trans,
'Non-Unit', m, n, one,
262 ELSE IF( n2.EQ.0 )
THEN
263 CALL ctrmm( side,
'Lower', trans,
'Non-Unit', m, n, one,
271 nb = max( 1, min( lwork, lwkopt ) / nq )
276 len = min( nb, n-i+1 )
281 CALL clacpy(
'All', n1, len, c( n2+1, i ), ldc, work,
283 CALL ctrmm(
'Left',
'Lower',
'No Transpose',
285 $ n1, len, one, q( 1, n2+1 ), ldq, work,
290 CALL cgemm(
'No Transpose',
'No Transpose', n1, len,
292 $ one, q, ldq, c( 1, i ), ldc, one, work,
297 CALL clacpy(
'All', n2, len, c( 1, i ), ldc,
298 $ work( n1+1 ), ldwork )
299 CALL ctrmm(
'Left',
'Upper',
'No Transpose',
301 $ n2, len, one, q( n1+1, 1 ), ldq,
302 $ work( n1+1 ), ldwork )
306 CALL cgemm(
'No Transpose',
'No Transpose', n2, len,
308 $ one, q( n1+1, n2+1 ), ldq, c( n2+1, i ), ldc,
309 $ one, work( n1+1 ), ldwork )
313 CALL clacpy(
'All', m, len, work, ldwork, c( 1, i ),
318 len = min( nb, n-i+1 )
323 CALL clacpy(
'All', n2, len, c( n1+1, i ), ldc, work,
325 CALL ctrmm(
'Left',
'Upper',
'Conjugate',
'Non-Unit',
326 $ n2, len, one, q( n1+1, 1 ), ldq, work,
331 CALL cgemm(
'Conjugate',
'No Transpose', n2, len, n1,
332 $ one, q, ldq, c( 1, i ), ldc, one, work,
337 CALL clacpy(
'All', n1, len, c( 1, i ), ldc,
338 $ work( n2+1 ), ldwork )
339 CALL ctrmm(
'Left',
'Lower',
'Conjugate',
'Non-Unit',
340 $ n1, len, one, q( 1, n2+1 ), ldq,
341 $ work( n2+1 ), ldwork )
345 CALL cgemm(
'Conjugate',
'No Transpose', n1, len, n2,
346 $ one, q( n1+1, n2+1 ), ldq, c( n1+1, i ), ldc,
347 $ one, work( n2+1 ), ldwork )
351 CALL clacpy(
'All', m, len, work, ldwork, c( 1, i ),
358 len = min( nb, m-i+1 )
363 CALL clacpy(
'All', len, n2, c( i, n1+1 ), ldc, work,
365 CALL ctrmm(
'Right',
'Upper',
'No Transpose',
367 $ len, n2, one, q( n1+1, 1 ), ldq, work,
372 CALL cgemm(
'No Transpose',
'No Transpose', len, n2,
374 $ one, c( i, 1 ), ldc, q, ldq, one, work,
379 CALL clacpy(
'All', len, n1, c( i, 1 ), ldc,
380 $ work( 1 + n2*ldwork ), ldwork )
381 CALL ctrmm(
'Right',
'Lower',
'No Transpose',
383 $ len, n1, one, q( 1, n2+1 ), ldq,
384 $ work( 1 + n2*ldwork ), ldwork )
388 CALL cgemm(
'No Transpose',
'No Transpose', len, n1,
390 $ one, c( i, n1+1 ), ldc, q( n1+1, n2+1 ), ldq,
391 $ one, work( 1 + n2*ldwork ), ldwork )
395 CALL clacpy(
'All', len, n, work, ldwork, c( i, 1 ),
400 len = min( nb, m-i+1 )
405 CALL clacpy(
'All', len, n1, c( i, n2+1 ), ldc, work,
407 CALL ctrmm(
'Right',
'Lower',
'Conjugate',
'Non-Unit',
408 $ len, n1, one, q( 1, n2+1 ), ldq, work,
413 CALL cgemm(
'No Transpose',
'Conjugate', len, n1, n2,
414 $ one, c( i, 1 ), ldc, q, ldq, one, work,
419 CALL clacpy(
'All', len, n2, c( i, 1 ), ldc,
420 $ work( 1 + n1*ldwork ), ldwork )
421 CALL ctrmm(
'Right',
'Upper',
'Conjugate',
'Non-Unit',
422 $ len, n2, one, q( n1+1, 1 ), ldq,
423 $ work( 1 + n1*ldwork ), ldwork )
427 CALL cgemm(
'No Transpose',
'Conjugate', len, n2, n1,
428 $ one, c( i, n2+1 ), ldc, q( n1+1, n2+1 ), ldq,
429 $ one, work( 1 + n1*ldwork ), ldwork )
433 CALL clacpy(
'All', len, n, work, ldwork, c( i, 1 ),
439 work( 1 ) = cmplx( lwkopt )