1 SUBROUTINE pzlarfc( 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,
339 tauloc = dconjg( tau( iiv ) )
343 CALL zgebr2d( ictxt,
'Columnwise',
' ', 1, 1,
344 $ tauloc, 1, ivrow, mycol )
345 tauloc = dconjg( tauloc )
349 IF( tauloc.NE.zero )
THEN
354 CALL zgemv(
'Conjugate transpose', mp, nq, one,
355 $ c( ioffc ), ldc, work, 1, zero,
358 CALL zlaset(
'All', nq, 1, zero, zero,
359 $ work( ipw ),
max( 1, nq ) )
361 CALL zgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
362 $ work( ipw ),
max( 1, nq ), rdest,
367 CALL zgerc( mp, nq, -tauloc, work, 1, work( ipw ),
368 $ 1, c( ioffc ), ldc )
377 IF( ivcol.EQ.iccol )
THEN
381 IF( mycol.EQ.iccol )
THEN
383 tauloc = dconjg( tau( jjv ) )
385 IF( tauloc.NE.zero )
THEN
390 CALL zgemv(
'Conjugate transpose', mp, nq,
391 $ one, c( ioffc ), ldc, v( ioffv ), 1,
394 CALL zlaset(
'All', nq, 1, zero, zero,
395 $ work,
max( 1, nq ) )
397 CALL zgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
398 $ work,
max( 1, nq ), rdest, mycol )
402 CALL zgerc( mp, nq, -tauloc, v( ioffv ), 1,
403 $ work, 1, c( ioffc ), ldc )
412 IF( mycol.EQ.ivcol )
THEN
415 CALL zcopy( mp, v( ioffv ), 1, work, 1 )
416 work( ipw ) = tau( jjv )
417 CALL zgesd2d( ictxt, ipw, 1, work, ipw, myrow,
420 ELSE IF( mycol.EQ.iccol )
THEN
423 CALL zgerv2d( ictxt, ipw, 1, work, ipw, myrow,
425 tauloc = dconjg( work( ipw ) )
427 IF( tauloc.NE.zero )
THEN
432 CALL zgemv(
'Conjugate transpose', mp, nq,
433 $ one, c( ioffc ), ldc, work, 1,
434 $ zero, work( ipw ), 1 )
436 CALL zlaset(
'All', nq, 1, zero, zero,
437 $ work( ipw ),
max( 1, nq ) )
439 CALL zgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
440 $ work( ipw ),
max( 1, nq ), rdest,
445 CALL zgerc( mp, nq, -tauloc, work, 1,
446 $ work( ipw ), 1, c( ioffc ), ldc )
459 IF( descv( m_ ).EQ.incv )
THEN
464 CALL pbztrnv( ictxt,
'Rowwise',
'Transpose', m,
465 $ descv( nb_ ), iroff, v( ioffv ), ldv, zero,
466 $ work, 1, ivrow, ivcol, icrow, -1,
471 IF( myrow.EQ.ivrow )
THEN
473 CALL zgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
475 tauloc = dconjg( tau( iiv ) )
479 CALL zgebr2d( ictxt,
'Columnwise',
' ', 1, 1, tauloc,
481 tauloc = dconjg( tauloc )
485 IF( tauloc.NE.zero )
THEN
490 CALL zgemv(
'Conjugate transpose', mp, nq, one,
491 $ c( ioffc ), ldc, work, 1, zero,
494 CALL zlaset(
'All', nq, 1, zero, zero,
495 $ work( ipw ),
max( 1, nq ) )
497 CALL zgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
498 $ work( ipw ),
max( 1, nq ), rdest,
503 CALL zgerc( mp, nq, -tauloc, work, 1, work( ipw ), 1,
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,
519 tauloc = dconjg( tau( jjv ) )
524 CALL zgebr2d( ictxt,
'Rowwise', rowbtop, ipw, 1, work,
525 $ ipw, myrow, ivcol )
526 tauloc = dconjg( work( ipw ) )
530 IF( tauloc.NE.zero )
THEN
535 CALL zgemv(
'Conjugate transpose', mp, nq, one,
536 $ c( ioffc ), ldc, work, 1, zero,
539 CALL zlaset(
'All', nq, 1, zero, zero,
540 $ work( ipw ),
max( 1, nq ) )
542 CALL zgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
543 $ work( ipw ),
max( 1, nq ), rdest,
548 CALL zgerc( mp, nq, -tauloc, work, 1, work( ipw ), 1,
568 IF( descv( m_ ).EQ.incv )
THEN
572 IF( ivrow.EQ.icrow )
THEN
576 IF( myrow.EQ.icrow )
THEN
578 tauloc = dconjg( tau( iiv ) )
580 IF( tauloc.NE.zero )
THEN
585 CALL zgemv(
'No transpose', mp, nq, one,
586 $ c( ioffc ), ldc, v( ioffv ), ldv,
589 CALL zlaset(
'All', mp, 1, zero, zero,
590 $ work,
max( 1, mp ) )
592 CALL zgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
593 $ work,
max( 1, mp ), rdest, iccol )
597 CALL zgerc( mp, nq, -tauloc, work, 1,
598 $ v( ioffv ), ldv, c( ioffc ), ldc )
607 IF( myrow.EQ.ivrow )
THEN
610 CALL zcopy( nq, v( ioffv ), ldv, work, 1 )
611 work(ipw) = tau( iiv )
612 CALL zgesd2d( ictxt, ipw, 1, work, ipw, icrow,
615 ELSE IF( myrow.EQ.icrow )
THEN
618 CALL zgerv2d( ictxt, ipw, 1, work, ipw, ivrow,
620 tauloc = dconjg( work( ipw ) )
622 IF( tauloc.NE.zero )
THEN
627 CALL zgemv(
'No transpose', mp, nq, one,
628 $ c( ioffc ), ldc, work, 1, zero,
631 CALL zlaset(
'All', mp, 1, zero, zero,
632 $ work( ipw ),
max( 1, mp ) )
634 CALL zgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
635 $ work( ipw ),
max( 1, mp ), rdest,
640 CALL zgerc( mp, nq, -tauloc, work( ipw ), 1,
641 $ work, 1, c( ioffc ), ldc )
653 CALL pbztrnv( ictxt,
'Columnwise',
'Transpose', n,
654 $ descv( mb_ ), icoff, v( ioffv ), 1, zero,
655 $ work, 1, ivrow, ivcol, icrow, iccol,
660 IF( myrow.EQ.icrow )
THEN
662 IF( mycol.EQ.ivcol )
THEN
664 CALL zgebs2d( ictxt,
'Rowwise',
' ', 1, 1,
666 tauloc = dconjg( tau( jjv ) )
670 CALL zgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc,
672 tauloc = dconjg( tauloc )
676 IF( tauloc.NE.zero )
THEN
681 CALL zgemv(
'No transpose', mp, nq, one,
682 $ c( ioffc ), ldc, work, 1, zero,
685 CALL zlaset(
'All', mp, 1, zero, zero,
686 $ work( ipw ),
max( 1, mp ) )
688 CALL zgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
689 $ work( ipw ),
max( 1, mp ), rdest,
694 CALL zgerc( mp, nq, -tauloc, work( ipw ), 1, work,
695 $ 1, c( ioffc ), ldc )
706 IF( descv( m_ ).EQ.incv )
THEN
710 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise',
712 IF( myrow.EQ.ivrow )
THEN
715 CALL zcopy( nq, v( ioffv ), ldv, work, 1 )
716 work(ipw) = tau( iiv )
717 CALL zgebs2d( ictxt,
'Columnwise', colbtop, ipw, 1,
719 tauloc = dconjg( tau( iiv ) )
724 CALL zgebr2d( ictxt,
'Columnwise', colbtop, ipw, 1,
725 $ work, ipw, ivrow, mycol )
726 tauloc = dconjg( work( ipw ) )
730 IF( tauloc.NE.zero )
THEN
735 CALL zgemv(
'No Transpose', mp, nq, one,
736 $ c( ioffc ), ldc, work, 1, zero,
739 CALL zlaset(
'All', mp, 1, zero, zero,
740 $ work( ipw ),
max( 1, mp ) )
742 CALL zgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
743 $ work( ipw ),
max( 1, mp ), rdest,
748 CALL zgerc( mp, nq, -tauloc, work( ipw ), 1, work, 1,
757 CALL pbztrnv( ictxt,
'Columnwise',
'Transpose', n,
758 $ descv( mb_ ), icoff, v( ioffv ), 1, zero,
759 $ work, 1, ivrow, ivcol, -1, iccol,
764 IF( mycol.EQ.ivcol )
THEN
766 CALL zgebs2d( ictxt,
'Rowwise',
' ', 1, 1, tau( jjv ),
768 tauloc = dconjg( tau( jjv ) )
772 CALL zgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc, 1,
774 tauloc = dconjg( tauloc )
778 IF( tauloc.NE.zero )
THEN
783 CALL zgemv(
'No transpose', mp, nq, one,
784 $ c( ioffc ), ldc, work, 1, zero,
787 CALL zlaset(
'All', mp, 1, zero, zero, work( ipw ),
790 CALL zgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
791 $ work( ipw ),
max( 1, mp ), rdest,
796 CALL zgerc( mp, nq, -tauloc, work( ipw ), 1, work, 1,