1 SUBROUTINE pzunmrq( SIDE, TRANS, M, N, K, A, IA, JA, DESCA, TAU,
2 $ C, IC, JC, DESCC, WORK, LWORK, INFO )
11 INTEGER IA, IC, INFO, JA, JC, K, LWORK, M, N
14 INTEGER DESCA( * ), DESCC( * )
15 COMPLEX*16 A( * ), C( * ), TAU( * ), WORK( * )
219 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
220 $ lld_, mb_, m_, nb_, n_, rsrc_
221 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
222 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
223 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
226 LOGICAL LEFT, LQUERY, NOTRAN, RIGHT, TRAN
227 CHARACTER COLBTOP, ROWBTOP, TRANST
228 INTEGER I, I1, I2, I3, IACOL, IB, ICCOL, ICOFFA,
229 $ icoffc, icrow, ictxt, iinfo, ipw, iroffc, lcm,
230 $ lcmp, lwmin, mi, mpc0, mqa0, mycol, myrow, ni,
231 $ npcol, nprow, nq, nqc0
234 INTEGER IDUM1( 4 ), IDUM2( 4 )
243 INTEGER ICEIL, ILCM, INDXG2P, NUMROC
244 EXTERNAL iceil, ilcm, indxg2p, lsame, numroc
247 INTRINSIC dble, dcmplx, ichar,
max,
min, mod
253 ictxt = desca( ctxt_ )
254 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
259 IF( nprow.EQ.-1 )
THEN
262 IF( lsame( side,
'L' ) )
THEN
269 IF( lsame( trans,
'N' ) )
THEN
281 CALL chk1mat( k, 5, m, 3, ia, ja, desca, 9, info )
284 CALL chk1mat( k, 5, n, 4, ia, ja, desca, 9, info )
286 CALL chk1mat( m, 3, n, 4, ic, jc, descc, 14, info )
288 icoffa = mod( ja-1, desca( nb_ ) )
289 iroffc = mod( ic-1, descc( mb_ ) )
290 icoffc = mod( jc-1, descc( nb_ ) )
291 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
293 icrow = indxg2p( ic, descc( mb_ ), myrow, descc( rsrc_ ),
295 iccol = indxg2p( jc, descc( nb_ ), mycol, descc( csrc_ ),
297 mpc0 = numroc( m+iroffc, descc( mb_ ), myrow, icrow, nprow )
298 nqc0 = numroc( n+icoffc, descc( nb_ ), mycol, iccol, npcol )
301 mqa0 = numroc( m+icoffa, desca( nb_ ), mycol, iacol,
303 lcm = ilcm( nprow, npcol )
305 lwmin =
max( ( desca( mb_ ) * ( desca( mb_ ) - 1 ) )
306 $ / 2, ( mpc0 +
max( mqa0 + numroc( numroc(
307 $ m+iroffc, desca( mb_ ), 0, 0, nprow ),
308 $ desca( mb_ ), 0, 0, lcmp ), nqc0 ) ) *
309 $ desca( mb_ ) ) + desca( mb_ ) * desca( mb_ )
311 lwmin =
max( ( desca( mb_ ) * ( desca( mb_ ) - 1 ) ) / 2,
312 $ ( mpc0 + nqc0 ) * desca( mb_ ) ) +
313 $ desca( mb_ ) * desca( mb_ )
316 work( 1 ) = dcmplx( dble( lwmin ) )
317 lquery = ( lwork.EQ.-1 )
318 IF( .NOT.left .AND. .NOT.lsame( side,
'R' ) )
THEN
320 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans,
'C' ) )
THEN
322 ELSE IF( k.LT.0 .OR. k.GT.nq )
THEN
324 ELSE IF( left .AND. desca( nb_ ).NE.descc( mb_ ) )
THEN
326 ELSE IF( left .AND. icoffa.NE.iroffc )
THEN
328 ELSE IF( .NOT.left .AND. icoffa.NE.icoffc )
THEN
330 ELSE IF( .NOT.left .AND. iacol.NE.iccol )
THEN
332 ELSE IF( .NOT.left .AND. desca( nb_ ).NE.descc( nb_ ) )
THEN
334 ELSE IF( ictxt.NE.descc( ctxt_ ) )
THEN
336 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
341 idum1( 1 ) = ichar(
'L' )
343 idum1( 1 ) = ichar(
'R' )
347 idum1( 2 ) = ichar(
'N' )
349 idum1( 2 ) = ichar(
'C' )
354 IF( lwork.EQ.-1 )
THEN
361 CALL pchk2mat( k, 5, m, 3, ia, ja, desca, 9, m, 3, n, 4,
362 $ ic, jc, descc, 14, 4, idum1, idum2, info )
364 CALL pchk2mat( k, 5, n, 4, ia, ja, desca, 9, m, 3, n, 4,
365 $ ic, jc, descc, 14, 4, idum1, idum2, info )
370 CALL pxerbla( ictxt,
'PZUNMRQ', -info )
372 ELSE IF( lquery )
THEN
378 IF( m.EQ.0 .OR. n.EQ.0 .OR. k.EQ.0 )
381 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
382 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
384 IF( ( left .AND. .NOT.notran ) .OR.
385 $ ( .NOT.left .AND. notran ) )
THEN
386 i1 =
min( iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+k-1 )
391 i1 =
max( ( (ia+k-2) / desca( mb_ ) ) * desca( mb_ ) + 1, ia )
392 i2 =
min( iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+k-1 )
401 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
' ' )
403 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
'I-ring' )
405 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
'D-ring' )
415 IF( ( left .AND. .NOT.notran ) .OR.
416 $ ( .NOT.left .AND. notran ) )
THEN
423 CALL pzunmr2( side, trans, mi, ni, ib, a, ia, ja, desca, tau,
424 $ c, ic, jc, descc, work, lwork, iinfo )
427 ipw = desca( mb_ )*desca( mb_ ) + 1
429 ib =
min( desca( mb_ ), k-i+ia )
434 CALL pzlarft(
'Backward',
'Rowwise', nq-k+i+ib-ia, ib,
435 $ a, i, ja, desca, tau, work, work( ipw ) )
440 mi = m - k + i + ib - ia
445 ni = n - k + i + ib - ia
450 CALL pzlarfb( side, transt,
'Backward',
'Rowwise', mi, ni,
451 $ ib, a, i, ja, desca, work, c, ic, jc, descc,
455 IF( ( right .AND. tran ) .OR.
456 $ ( left .AND. notran ) )
THEN
463 CALL pzunmr2( side, trans, mi, ni, ib, a, ia, ja, desca, tau,
464 $ c, ic, jc, descc, work, lwork, iinfo )
467 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
468 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
470 work( 1 ) = dcmplx( dble( lwmin ) )