1 SUBROUTINE pzlarf( SIDE, M, N, V, IV, JV, DESCV, INCV, TAU,
2 $ C, IC, JC, DESCC, WORK )
11 INTEGER IC, INCV, IV, JC, JV, M, N
14 INTEGER DESCC( * ), DESCV( * )
15 COMPLEX*16 C( * ), TAU( * ), V( * ), WORK( * )
229 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
230 $ lld_, mb_, m_, nb_, n_, rsrc_
231 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
232 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
233 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
235 parameter( one = ( 1.0d+0, 0.0d+0 ),
236 $ zero = ( 0.0d+0, 0.0d+0 ) )
239 LOGICAL CCBLCK, CRBLCK
240 CHARACTER COLBTOP, ROWBTOP
241 INTEGER ICCOL, ICOFF, ICROW, ICTXT, IIC, IIV, IOFFC,
242 $ ioffv, ipw, iroff, ivcol, ivrow, jjc, jjv, ldc,
243 $ ldv, mycol, myrow, mp, ncc, ncv, npcol, nprow,
249 $ zcopy, zgebr2d, zgebs2d, zgemv,
250 $ zgerc, zgerv2d, zgesd2d, zgsum2d,
256 EXTERNAL lsame, numroc
265 IF( m.LE.0 .OR. n.LE.0 )
270 ictxt = descc( ctxt_ )
271 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
275 CALL infog2l( ic, jc, descc, nprow, npcol, myrow, mycol, iic, jjc,
277 CALL infog2l( iv, jv, descv, nprow, npcol, myrow, mycol, iiv, jjv,
279 ncc = numroc( descc( n_ ), descc( nb_ ), mycol, descc( csrc_ ),
281 ncv = numroc( descv( n_ ), descv( nb_ ), mycol, descv( csrc_ ),
285 iic =
min( iic, ldc )
286 iiv =
min( iiv, ldv )
287 jjc =
min( jjc, ncc )
288 jjv =
min( jjv, ncv )
289 ioffc = iic+(jjc-1)*ldc
290 ioffv = iiv+(jjv-1)*ldv
292 iroff = mod( ic-1, descc( mb_ ) )
293 icoff = mod( jc-1, descc( nb_ ) )
294 mp = numroc( m+iroff, descc( mb_ ), myrow, icrow, nprow )
295 nq = numroc( n+icoff, descc( nb_ ), mycol, iccol, npcol )
303 crblck = ( m.LE.(descc( mb_ )-iroff) )
307 ccblck = ( n.LE.(descc( nb_ )-icoff) )
309 IF( lsame( side,
'L' ) )
THEN
321 IF( descv( m_ ).EQ.incv )
THEN
326 CALL pbztrnv( ictxt,
'Rowwise',
'Transpose', m,
327 $ descv( nb_ ), iroff, v( ioffv ), ldv, zero,
328 $ work, 1, ivrow, ivcol, icrow, iccol,
333 IF( mycol.EQ.iccol )
THEN
335 IF( myrow.EQ.ivrow )
THEN
337 CALL zgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
343 CALL zgebr2d( ictxt,
'Columnwise',
' ', 1, 1,
344 $ tauloc, 1, ivrow, mycol )
348 IF( tauloc.NE.zero )
THEN
353 CALL zgemv(
'Conjugate transpose', mp, nq, one,
354 $ c( ioffc ), ldc, work, 1, zero,
357 CALL zlaset(
'All', nq, 1, zero, zero,
358 $ work( ipw ),
max( 1, nq ) )
360 CALL zgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
361 $ work( ipw ),
max( 1, nq ), rdest,
366 CALL zgerc( mp, nq, -tauloc, work, 1, work( ipw ),
367 $ 1, c( ioffc ), ldc )
376 IF( ivcol.EQ.iccol )
THEN
380 IF( mycol.EQ.iccol )
THEN
384 IF( tauloc.NE.zero )
THEN
389 CALL zgemv(
'Conjugate transpose', mp, nq,
390 $ one, c( ioffc ), ldc, v( ioffv ), 1,
393 CALL zlaset(
'All', nq, 1, zero, zero,
394 $ work,
max( 1, nq ) )
396 CALL zgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
397 $ work,
max( 1, nq ), rdest, mycol )
401 CALL zgerc( mp, nq, -tauloc, v( ioffv ), 1,
402 $ work, 1, c( ioffc ), ldc )
411 IF( mycol.EQ.ivcol )
THEN
414 CALL zcopy( mp, v( ioffv ), 1, work, 1 )
415 work( ipw ) = tau( jjv )
416 CALL zgesd2d( ictxt, ipw, 1, work, ipw, myrow,
419 ELSE IF( mycol.EQ.iccol )
THEN
422 CALL zgerv2d( ictxt, ipw, 1, work, ipw, myrow,
426 IF( tauloc.NE.zero )
THEN
431 CALL zgemv(
'Conjugate transpose', mp, nq,
432 $ one, c( ioffc ), ldc, work, 1,
433 $ zero, work( ipw ), 1 )
435 CALL zlaset(
'All', nq, 1, zero, zero,
436 $ work( ipw ),
max( 1, nq ) )
438 CALL zgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
439 $ work( ipw ),
max( 1, nq ), rdest,
444 CALL zgerc( mp, nq, -tauloc, work, 1,
445 $ work( ipw ), 1, c( ioffc ), ldc )
458 IF( descv( m_ ).EQ.incv )
THEN
463 CALL pbztrnv( ictxt,
'Rowwise',
'Transpose', m,
464 $ descv( nb_ ), iroff, v( ioffv ), ldv, zero,
465 $ work, 1, ivrow, ivcol, icrow, -1,
470 IF( myrow.EQ.ivrow )
THEN
472 CALL zgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
478 CALL zgebr2d( ictxt,
'Columnwise',
' ', 1, 1, tauloc,
483 IF( tauloc.NE.zero )
THEN
489 $
CALL zgemv(
'Conjugate transpose', mp, nq, one,
490 $ c( ioffc ), ldc, work, 1, zero,
493 CALL zlaset(
'All', nq, 1, zero, zero,
494 $ work( ipw ),
max( 1, nq ) )
496 CALL zgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
497 $ work( ipw ),
max( 1, nq ), rdest,
503 $
CALL zgerc( mp, nq, -tauloc, work, 1, work( ipw ),
504 $ 1, c( ioffc ), ldc )
511 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
512 IF( mycol.EQ.ivcol )
THEN
515 CALL zcopy( mp, v( ioffv ), 1, work, 1 )
516 work(ipw) = tau( jjv )
517 CALL zgebs2d( ictxt,
'Rowwise', rowbtop, ipw, 1,
524 CALL zgebr2d( ictxt,
'Rowwise', rowbtop, ipw, 1, work,
525 $ ipw, myrow, ivcol )
530 IF( tauloc.NE.zero )
THEN
536 $
CALL zgemv(
'Conjugate transpose', mp, nq, one,
537 $ c( ioffc ), ldc, work, 1, zero,
540 CALL zlaset(
'All', nq, 1, zero, zero,
541 $ work( ipw ),
max( 1, nq ) )
543 CALL zgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
544 $ work( ipw ),
max( 1, nq ), rdest,
550 $
CALL zgerc( mp, nq, -tauloc, work, 1, work( ipw ),
551 $ 1, c( ioffc ), ldc )
570 IF( descv( m_ ).EQ.incv )
THEN
574 IF( ivrow.EQ.icrow )
THEN
578 IF( myrow.EQ.icrow )
THEN
582 IF( tauloc.NE.zero )
THEN
587 CALL zgemv(
'No transpose', mp, nq, one,
588 $ c( ioffc ), ldc, v( ioffv ), ldv,
591 CALL zlaset(
'All', mp, 1, zero, zero,
592 $ work,
max( 1, mp ) )
594 CALL zgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
595 $ work,
max( 1, mp ), rdest, iccol )
599 IF( ioffv.GT.0 .AND. ioffc.GT.0 )
600 $
CALL zgerc( mp, nq, -tauloc, work, 1,
601 $ v( ioffv ), ldv, c( ioffc ),
611 IF( myrow.EQ.ivrow )
THEN
614 CALL zcopy( nq, v( ioffv ), ldv, work, 1 )
615 work(ipw) = tau( iiv )
616 CALL zgesd2d( ictxt, ipw, 1, work, ipw, icrow,
619 ELSE IF( myrow.EQ.icrow )
THEN
622 CALL zgerv2d( ictxt, ipw, 1, work, ipw, ivrow,
626 IF( tauloc.NE.zero )
THEN
631 CALL zgemv(
'No transpose', mp, nq, one,
632 $ c( ioffc ), ldc, work, 1, zero,
635 CALL zlaset(
'All', mp, 1, zero, zero,
636 $ work( ipw ),
max( 1, mp ) )
638 CALL zgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
639 $ work( ipw ),
max( 1, mp ), rdest,
644 CALL zgerc( mp, nq, -tauloc, work( ipw ), 1,
645 $ work, 1, c( ioffc ), ldc )
657 CALL pbztrnv( ictxt,
'Columnwise',
'Transpose', n,
658 $ descv( mb_ ), icoff, v( ioffv ), 1, zero,
659 $ work, 1, ivrow, ivcol, icrow, iccol,
664 IF( myrow.EQ.icrow )
THEN
666 IF( mycol.EQ.ivcol )
THEN
668 CALL zgebs2d( ictxt,
'Rowwise',
' ', 1, 1,
674 CALL zgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc,
679 IF( tauloc.NE.zero )
THEN
684 CALL zgemv(
'No transpose', mp, nq, one,
685 $ c( ioffc ), ldc, work, 1, zero,
688 CALL zlaset(
'All', mp, 1, zero, zero,
689 $ work( ipw ),
max( 1, mp ) )
691 CALL zgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
692 $ work( ipw ),
max( 1, mp ), rdest,
697 CALL zgerc( mp, nq, -tauloc, work( ipw ), 1, work,
698 $ 1, c( ioffc ), ldc )
709 IF( descv( m_ ).EQ.incv )
THEN
713 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise',
715 IF( myrow.EQ.ivrow )
THEN
719 $
CALL zcopy( nq, v( ioffv ), ldv, work, 1 )
720 work(ipw) = tau( iiv )
721 CALL zgebs2d( ictxt,
'Columnwise', colbtop, ipw, 1,
728 CALL zgebr2d( ictxt,
'Columnwise', colbtop, ipw, 1,
729 $ work, ipw, ivrow, mycol )
734 IF( tauloc.NE.zero )
THEN
739 CALL zgemv(
'No Transpose', mp, nq, one,
740 $ c( ioffc ), ldc, work, 1, zero,
743 CALL zlaset(
'All', mp, 1, zero, zero,
744 $ work( ipw ),
max( 1, mp ) )
746 CALL zgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
747 $ work( ipw ),
max( 1, mp ), rdest,
753 $
CALL zgerc( mp, nq, -tauloc, work( ipw ), 1, work,
754 $ 1, c( ioffc ), ldc )
762 CALL pbztrnv( ictxt,
'Columnwise',
'Transpose', n,
763 $ descv( mb_ ), icoff, v( ioffv ), 1, zero,
764 $ work, 1, ivrow, ivcol, -1, iccol,
769 IF( mycol.EQ.ivcol )
THEN
771 CALL zgebs2d( ictxt,
'Rowwise',
' ', 1, 1, tau( jjv ),
777 CALL zgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc, 1,
782 IF( tauloc.NE.zero )
THEN
787 CALL zgemv(
'No transpose', mp, nq, one,
788 $ c( ioffc ), ldc, work, 1, zero,
791 CALL zlaset(
'All', mp, 1, zero, zero, work( ipw ),
794 CALL zgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
795 $ work( ipw ),
max( 1, mp ), rdest,
800 CALL zgerc( mp, nq, -tauloc, work( ipw ), 1, work, 1,