1 SUBROUTINE pslarf( 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 REAL 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.0e+0, zero = 0.0e+0 )
238 LOGICAL CCBLCK, CRBLCK
239 CHARACTER COLBTOP, ROWBTOP
240 INTEGER ICCOL, ICOFF, ICROW, ICTXT, IIC, IIV, IOFFC,
241 $ ioffv, ipw, iroff, ivcol, ivrow, jjc, jjv, ldc,
242 $ ldv, mycol, myrow, mp, ncc, ncv, npcol, nprow,
248 $ scopy, sgebr2d, sgebs2d, sgemv,
249 $ sger, sgerv2d, sgesd2d, sgsum2d,
255 EXTERNAL lsame, numroc
264 IF( m.LE.0 .OR. n.LE.0 )
269 ictxt = descc( ctxt_ )
270 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
274 CALL infog2l( ic, jc, descc, nprow, npcol, myrow, mycol, iic, jjc,
276 CALL infog2l( iv, jv, descv, nprow, npcol, myrow, mycol, iiv, jjv,
278 ncc = numroc( descc( n_ ), descc( nb_ ), mycol, descc( csrc_ ),
280 ncv = numroc( descv( n_ ), descv( nb_ ), mycol, descv( csrc_ ),
284 iic =
min( iic, ldc )
285 iiv =
min( iiv, ldv )
286 jjc =
min( jjc, ncc )
287 jjv =
min( jjv, ncv )
288 ioffc = iic+(jjc-1)*ldc
289 ioffv = iiv+(jjv-1)*ldv
291 iroff = mod( ic-1, descc( mb_ ) )
292 icoff = mod( jc-1, descc( nb_ ) )
293 mp = numroc( m+iroff, descc( mb_ ), myrow, icrow, nprow )
294 nq = numroc( n+icoff, descc( nb_ ), mycol, iccol, npcol )
302 crblck = ( m.LE.(descc( mb_ )-iroff) )
306 ccblck = ( n.LE.(descc( nb_ )-icoff) )
308 IF( lsame( side,
'L' ) )
THEN
320 IF( descv( m_ ).EQ.incv )
THEN
325 CALL pbstrnv( ictxt,
'Rowwise',
'Transpose', m,
326 $ descv( nb_ ), iroff, v( ioffv ), ldv, zero,
327 $ work, 1, ivrow, ivcol, icrow, iccol,
332 IF( mycol.EQ.iccol )
THEN
334 IF( myrow.EQ.ivrow )
THEN
336 CALL sgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
342 CALL sgebr2d( ictxt,
'Columnwise',
' ', 1, 1,
343 $ tauloc, 1, ivrow, mycol )
347 IF( tauloc.NE.zero )
THEN
352 CALL sgemv(
'Transpose', mp, nq, one,
353 $ c( ioffc ), ldc, work, 1, zero,
356 CALL slaset(
'All', nq, 1, zero, zero,
357 $ work( ipw ),
max( 1, nq ) )
359 CALL sgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
360 $ work( ipw ),
max( 1, nq ), rdest,
365 CALL sger( mp, nq, -tauloc, work, 1, work( ipw ),
366 $ 1, c( ioffc ), ldc )
375 IF( ivcol.EQ.iccol )
THEN
379 IF( mycol.EQ.iccol )
THEN
383 IF( tauloc.NE.zero )
THEN
388 CALL sgemv(
'Transpose', mp, nq, one,
389 $ c( ioffc ), ldc, v( ioffv ), 1,
392 CALL slaset(
'All', nq, 1, zero, zero,
393 $ work,
max( 1, nq ) )
395 CALL sgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
396 $ work,
max( 1, nq ), rdest, mycol )
400 CALL sger( mp, nq, -tauloc, v( ioffv ), 1, work,
401 $ 1, c( ioffc ), ldc )
410 IF( mycol.EQ.ivcol )
THEN
413 CALL scopy( mp, v( ioffv ), 1, work, 1 )
414 work( ipw ) = tau( jjv )
415 CALL sgesd2d( ictxt, ipw, 1, work, ipw, myrow,
418 ELSE IF( mycol.EQ.iccol )
THEN
421 CALL sgerv2d( ictxt, ipw, 1, work, ipw, myrow,
425 IF( tauloc.NE.zero )
THEN
430 CALL sgemv(
'Transpose', mp, nq, one,
431 $ c( ioffc ), ldc, work, 1, zero,
434 CALL slaset(
'All', nq, 1, zero, zero,
435 $ work( ipw ),
max( 1, nq ) )
437 CALL sgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
438 $ work( ipw ),
max( 1, nq ), rdest,
443 CALL sger( mp, nq, -tauloc, work, 1,
444 $ work( ipw ), 1, c( ioffc ), ldc )
457 IF( descv( m_ ).EQ.incv )
THEN
462 CALL pbstrnv( ictxt,
'Rowwise',
'Transpose', m,
463 $ descv( nb_ ), iroff, v( ioffv ), ldv, zero,
464 $ work, 1, ivrow, ivcol, icrow, -1,
469 IF( myrow.EQ.ivrow )
THEN
471 CALL sgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
477 CALL sgebr2d( ictxt,
'Columnwise',
' ', 1, 1, tauloc,
482 IF( tauloc.NE.zero )
THEN
488 $
CALL sgemv(
'Transpose', mp, nq, one,
489 $ c( ioffc ), ldc, work, 1, zero,
492 CALL slaset(
'All', nq, 1, zero, zero,
493 $ work( ipw ),
max( 1, nq ) )
495 CALL sgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
496 $ work( ipw ),
max( 1, nq ), rdest,
502 $
CALL sger( mp, nq, -tauloc, work, 1, work( ipw ),
503 $ 1, c( ioffc ), ldc )
510 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
511 IF( mycol.EQ.ivcol )
THEN
514 CALL scopy( mp, v( ioffv ), 1, work, 1 )
515 work(ipw) = tau( jjv )
516 CALL sgebs2d( ictxt,
'Rowwise', rowbtop, ipw, 1,
523 CALL sgebr2d( ictxt,
'Rowwise', rowbtop, ipw, 1, work,
524 $ ipw, myrow, ivcol )
529 IF( tauloc.NE.zero )
THEN
535 $
CALL sgemv(
'Transpose', mp, nq, one,
536 $ c( ioffc ), ldc, work, 1, zero,
539 CALL slaset(
'All', nq, 1, zero, zero,
540 $ work( ipw ),
max( 1, nq ) )
542 CALL sgsum2d( ictxt,
'Columnwise',
' ', nq, 1,
543 $ work( ipw ),
max( 1, nq ), rdest,
549 $
CALL sger( mp, nq, -tauloc, work, 1, work( ipw ),
550 $ 1, c( ioffc ), ldc )
569 IF( descv( m_ ).EQ.incv )
THEN
573 IF( ivrow.EQ.icrow )
THEN
577 IF( myrow.EQ.icrow )
THEN
581 IF( tauloc.NE.zero )
THEN
586 CALL sgemv(
'No transpose', mp, nq, one,
587 $ c( ioffc ), ldc, v( ioffv ), ldv,
590 CALL slaset(
'All', mp, 1, zero, zero,
591 $ work,
max( 1, mp ) )
593 CALL sgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
594 $ work,
max( 1, mp ), rdest, iccol )
598 IF( ioffv.GT.0 .AND. ioffc.GT.0 )
599 $
CALL sger( mp, nq, -tauloc, work, 1,
600 $ v( ioffv ), ldv, c( ioffc ), ldc )
609 IF( myrow.EQ.ivrow )
THEN
612 CALL scopy( nq, v( ioffv ), ldv, work, 1 )
613 work(ipw) = tau( iiv )
614 CALL sgesd2d( ictxt, ipw, 1, work, ipw, icrow,
617 ELSE IF( myrow.EQ.icrow )
THEN
620 CALL sgerv2d( ictxt, ipw, 1, work, ipw, ivrow,
624 IF( tauloc.NE.zero )
THEN
629 CALL sgemv(
'No transpose', mp, nq, one,
630 $ c( ioffc ), ldc, work, 1, zero,
633 CALL slaset(
'All', mp, 1, zero, zero,
634 $ work( ipw ),
max( 1, mp ) )
636 CALL sgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
637 $ work( ipw ),
max( 1, mp ), rdest,
642 CALL sger( mp, nq, -tauloc, work( ipw ), 1,
643 $ work, 1, c( ioffc ), ldc )
655 CALL pbstrnv( ictxt,
'Columnwise',
'Transpose', n,
656 $ descv( mb_ ), icoff, v( ioffv ), 1, zero,
657 $ work, 1, ivrow, ivcol, icrow, iccol,
662 IF( myrow.EQ.icrow )
THEN
664 IF( mycol.EQ.ivcol )
THEN
666 CALL sgebs2d( ictxt,
'Rowwise',
' ', 1, 1,
672 CALL sgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc,
677 IF( tauloc.NE.zero )
THEN
682 CALL sgemv(
'No transpose', mp, nq, one,
683 $ c( ioffc ), ldc, work, 1, zero,
686 CALL slaset(
'All', mp, 1, zero, zero,
687 $ work( ipw ),
max( 1, mp ) )
689 CALL sgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
690 $ work( ipw ),
max( 1, mp ), rdest,
695 CALL sger( mp, nq, -tauloc, work( ipw ), 1, work,
696 $ 1, c( ioffc ), ldc )
707 IF( descv( m_ ).EQ.incv )
THEN
711 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise',
713 IF( myrow.EQ.ivrow )
THEN
717 $
CALL scopy( nq, v( ioffv ), ldv, work, 1 )
718 work(ipw) = tau( iiv )
719 CALL sgebs2d( ictxt,
'Columnwise', colbtop, ipw, 1,
726 CALL sgebr2d( ictxt,
'Columnwise', colbtop, ipw, 1,
727 $ work, ipw, ivrow, mycol )
732 IF( tauloc.NE.zero )
THEN
737 CALL sgemv(
'No Transpose', mp, nq, one,
738 $ c( ioffc ), ldc, work, 1, zero,
741 CALL slaset(
'All', mp, 1, zero, zero,
742 $ work( ipw ),
max( 1, mp ) )
744 CALL sgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
745 $ work( ipw ),
max( 1, mp ), rdest,
751 $
CALL sger( mp, nq, -tauloc, work( ipw ), 1, work,
752 $ 1, c( ioffc ), ldc )
760 CALL pbstrnv( ictxt,
'Columnwise',
'Transpose', n,
761 $ descv( mb_ ), icoff, v( ioffv ), 1, zero,
762 $ work, 1, ivrow, ivcol, -1, iccol,
767 IF( mycol.EQ.ivcol )
THEN
769 CALL sgebs2d( ictxt,
'Rowwise',
' ', 1, 1, tau( jjv ),
775 CALL sgebr2d( ictxt,
'Rowwise',
' ', 1, 1, tauloc, 1,
780 IF( tauloc.NE.zero )
THEN
785 CALL sgemv(
'No transpose', mp, nq, one,
786 $ c( ioffc ), ldc, work, 1, zero,
789 CALL slaset(
'All', mp, 1, zero, zero, work( ipw ),
792 CALL sgsum2d( ictxt,
'Rowwise',
' ', mp, 1,
793 $ work( ipw ),
max( 1, mp ), rdest,
798 CALL sger( mp, nq, -tauloc, work( ipw ), 1, work, 1,