1 REAL FUNCTION PSLANSY( NORM, UPLO, N, A, IA, JA,
16 REAL a( * ), work( * )
164 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dtype_,
165 $ lld_, mb_, m_, nb_, n_, rsrc_
166 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
167 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
168 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
170 parameter( one = 1.0e+0, zero = 0.0e+0 )
173 INTEGER i, iarow, iacol, ib, icoff, ictxt, icurcol,
174 $ icurrow, ii, iia, in, iroff, icsr, icsr0,
175 $ ioffa, irsc, irsc0, irsr, irsr0, jj, jja, k,
176 $ lda, ll, mycol, myrow, np, npcol, nprow, nq
180 REAL ssq( 2 ), colssq( 2 )
184 $ saxpy,
scombssq, sgamx2d, sgsum2d,
185 $ sgebr2d, sgebs2d, slassq
193 INTRINSIC abs,
max,
min, mod, sqrt
199 ictxt = desca( ctxt_ )
200 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
201 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol,
202 $ iia, jja, iarow, iacol )
204 iroff = mod( ia-1, desca( mb_ ) )
205 icoff = mod( ja-1, desca( nb_ ) )
206 np =
numroc( n+iroff, desca( mb_ ), myrow, iarow, nprow )
207 nq =
numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
211 IF( myrow.EQ.iarow )
THEN
217 IF( mycol.EQ.iacol )
THEN
225 in =
min(
iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+n-1 )
270 ELSE IF(
lsame( norm,
'M' ) )
THEN
276 IF(
lsame( uplo,
'U' ) )
THEN
284 IF( mycol.EQ.iacol )
THEN
285 DO 20 k = (jj-1)*lda, (jj+ib-2)*lda, lda
288 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
304 IF( myrow.EQ.iarow )
THEN
305 DO 40 k = ii, ii+ib-1
306 IF( jj.LE.jja+nq-1 )
THEN
307 DO 30 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
308 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
315 ELSE IF( mycol.EQ.iacol )
THEN
319 icurrow = mod( iarow+1, nprow )
320 icurcol = mod( iacol+1, npcol )
324 DO 90 i = in+1, ia+n-1, desca( mb_ )
325 ib =
min( desca( mb_ ), ia+n-i )
329 IF( mycol.EQ.icurcol )
THEN
330 DO 60 k = (jj-1)*lda, (jj+ib-2)*lda, lda
333 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
336 IF( myrow.EQ.icurrow )
342 IF( myrow.EQ.icurrow )
348 IF( myrow.EQ.icurrow )
THEN
349 DO 80 k = ii, ii+ib-1
350 IF( jj.LE.jja+nq-1 )
THEN
351 DO 70 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
352 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
355 IF( mycol.EQ.icurcol )
359 ELSE IF( mycol.EQ.icurcol )
THEN
362 icurrow = mod( icurrow+1, nprow )
363 icurcol = mod( icurcol+1, npcol )
374 IF( mycol.EQ.iacol )
THEN
375 DO 110 k = (jj-1)*lda, (jj+ib-2)*lda, lda
376 IF( ii.LE.iia+np-1 )
THEN
377 DO 100 ll = ii, iia+np-1
378 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
393 IF( myrow.EQ.iarow )
THEN
396 DO 120 ll = (jja-1)*lda, (jj-2)*lda, lda
397 VALUE =
max(
VALUE, abs( a( ii+ll ) ) )
404 ELSE IF( mycol.EQ.iacol )
THEN
408 icurrow = mod( iarow+1, nprow )
409 icurcol = mod( iacol+1, npcol )
413 DO 180 i = in+1, ia+n-1, desca( mb_ )
414 ib =
min( desca( mb_ ), ia+n-i )
418 IF( mycol.EQ.icurcol )
THEN
419 DO 150 k = (jj-1)*lda, (jj+ib-2)*lda, lda
420 IF( ii.LE.iia+np-1 )
THEN
421 DO 140 ll = ii, iia+np-1
422 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
425 IF( myrow.EQ.icurrow )
431 IF( myrow.EQ.icurrow )
437 IF( myrow.EQ.icurrow )
THEN
440 DO 160 ll = (jja-1)*lda, (jj-2)*lda, lda
441 VALUE =
max(
VALUE, abs( a( ii+ll ) ) )
445 IF( mycol.EQ.icurcol )
448 ELSE IF( mycol.EQ.icurcol )
THEN
451 icurrow = mod( icurrow+1, nprow )
452 icurcol = mod( icurcol+1, npcol )
460 CALL sgamx2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, i, k, -1,
466 ELSE IF(
lsame( norm,
'I' ) .OR.
lsame( norm,
'O' ) .OR.
472 IF(
lsame( uplo,
'U' ) )
THEN
480 IF( mycol.EQ.iacol )
THEN
481 ioffa = ( jj - 1 ) * lda
485 DO 190 ll = iia, ii-1
486 sum = sum + abs( a( ll+ioffa ) )
490 work( jj+k-jja+icsr0 ) = sum
504 IF( myrow.EQ.iarow )
THEN
505 DO 220 k = ii, ii+ib-1
507 IF( jja+nq.GT.jj )
THEN
508 DO 210 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
509 sum = sum + abs( a( k+ll ) )
512 work( k-iia+irsc0 ) = sum
517 ELSE IF( mycol.EQ.iacol )
THEN
521 icurrow = mod( iarow+1, nprow )
522 icurcol = mod( iacol+1, npcol )
526 DO 270 i = in+1, ia+n-1, desca( mb_ )
527 ib =
min( desca( mb_ ), ia+n-i )
531 IF( mycol.EQ.icurcol )
THEN
532 ioffa = ( jj - 1 ) * lda
536 DO 230 ll = iia, ii-1
537 sum = sum + abs( a( ioffa+ll ) )
541 work( jj+k-jja+icsr0 ) = sum
542 IF( myrow.EQ.icurrow )
548 IF( myrow.EQ.icurrow )
555 IF( myrow.EQ.icurrow )
THEN
556 DO 260 k = ii, ii+ib-1
558 IF( jja+nq.GT.jj )
THEN
559 DO 250 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
560 sum = sum + abs( a( k+ll ) )
563 work( k-iia+irsc0 ) = sum
564 IF( mycol.EQ.icurcol )
568 ELSE IF( mycol.EQ.icurcol )
THEN
572 icurrow = mod( icurrow+1, nprow )
573 icurcol = mod( icurcol+1, npcol )
585 IF( mycol.EQ.iacol )
THEN
589 IF( iia+np.GT.ii )
THEN
590 DO 280 ll = ii, iia+np-1
591 sum = sum + abs( a( ioffa+ll ) )
595 work( jj+k-jja+icsr0 ) = sum
609 IF( myrow.EQ.iarow )
THEN
610 DO 310 k = ii, ii+ib-1
613 DO 300 ll = (jja-1)*lda, (jj-2)*lda, lda
614 sum = sum + abs( a( k+ll ) )
617 work( k-iia+irsc0 ) = sum
622 ELSE IF( mycol.EQ.iacol )
THEN
626 icurrow = mod( iarow+1, nprow )
627 icurcol = mod( iacol+1, npcol )
631 DO 360 i = in+1, ia+n-1, desca( mb_ )
632 ib =
min( desca( mb_ ), ia+n-i )
636 IF( mycol.EQ.icurcol )
THEN
637 ioffa = ( jj - 1 ) * lda
640 IF( iia+np.GT.ii )
THEN
641 DO 320 ll = ii, iia+np-1
642 sum = sum + abs( a( ll+ioffa ) )
646 work( jj+k-jja+icsr0 ) = sum
647 IF( myrow.EQ.icurrow )
653 IF( myrow.EQ.icurrow )
660 IF( myrow.EQ.icurrow )
THEN
661 DO 350 k = ii, ii+ib-1
664 DO 340 ll = (jja-1)*lda, (jj-2)*lda, lda
665 sum = sum + abs( a( k+ll ) )
668 work(k-iia+irsc0) = sum
669 IF( mycol.EQ.icurcol )
673 ELSE IF( mycol.EQ.icurcol )
THEN
677 icurrow = mod( icurrow+1, nprow )
678 icurcol = mod( icurcol+1, npcol )
690 CALL sgsum2d( ictxt,
'Columnwise',
' ', 1, nq, work( icsr ), 1,
694 CALL sgsum2d( ictxt,
'Rowwise',
' ', np, 1, work( irsc ),
695 $
max( 1, np ), myrow, iacol )
697 CALL pscol2row( ictxt, n, 1, desca( mb_ ), work( irsc ),
698 $
max( 1, np ), work( irsr ),
max( 1, nq ),
699 $ iarow, iacol, iarow, iacol, work( irsc+np ) )
701 IF( myrow.EQ.iarow )
THEN
704 CALL saxpy( nq, one, work( irsr0 ), 1, work( icsr0 ), 1 )
708 VALUE = work( isamax( nq, work( icsr0 ), 1 ) )
710 CALL sgamx2d( ictxt,
'Rowwise',
' ', 1, 1,
VALUE, 1, i, k,
719 ELSE IF(
lsame( norm,
'F' ) .OR.
lsame( norm,
'E' ) )
THEN
728 IF(
lsame( uplo,
'U' ) )
THEN
734 IF( mycol.EQ.iacol )
THEN
735 DO 370 k = (jj-1)*lda, (jj+ib-2)*lda, lda
738 CALL slassq( ii-iia, a( iia+k ), 1,
739 $ colssq(1), colssq(2) )
742 CALL slassq( ii-iia, a( iia+k ), 1,
743 $ colssq(1), colssq(2) )
748 ELSE IF( myrow.EQ.iarow )
THEN
752 icurrow = mod( iarow+1, nprow )
753 icurcol = mod( iacol+1, npcol )
757 DO 390 i = in+1, ia+n-1, desca( mb_ )
758 ib =
min( desca( mb_ ), ia+n-i )
760 IF( mycol.EQ.icurcol )
THEN
761 DO 380 k = (jj-1)*lda, (jj+ib-2)*lda, lda
764 CALL slassq( ii-iia, a( iia+k ), 1,
765 $ colssq(1), colssq(2) )
766 IF( myrow.EQ.icurrow )
768 CALL slassq( ii-iia, a(iia+k ), 1,
769 $ colssq(1), colssq(2) )
774 ELSE IF( myrow.EQ.icurrow )
THEN
778 icurrow = mod( icurrow+1, nprow )
779 icurcol = mod( icurcol+1, npcol )
789 IF( mycol.EQ.iacol )
THEN
790 DO 400 k = (jj-1)*lda, (jj+ib-2)*lda, lda
793 CALL slassq( iia+np-ii, a( ii+k ), 1,
794 $ colssq(1), colssq(2) )
797 CALL slassq( iia+np-ii, a( ii+k ), 1,
798 $ colssq(1), colssq(2) )
803 ELSE IF( myrow.EQ.iarow )
THEN
807 icurrow = mod( iarow+1, nprow )
808 icurcol = mod( iacol+1, npcol )
812 DO 420 i = in+1, ia+n-1, desca( mb_ )
813 ib =
min( desca( mb_ ), ia+n-i )
815 IF( mycol.EQ.icurcol )
THEN
816 DO 410 k = (jj-1)*lda, (jj+ib-2)*lda, lda
819 CALL slassq( iia+np-ii, a( ii+k ), 1,
820 $ colssq(1), colssq(2) )
821 IF( myrow.EQ.icurrow )
823 CALL slassq( iia+np-ii, a( ii+k ), 1,
824 $ colssq(1), colssq(2) )
829 ELSE IF( myrow.EQ.icurrow )
THEN
833 icurrow = mod( icurrow+1, nprow )
834 icurcol = mod( icurcol+1, npcol )
842 CALL pstreecomb( ictxt,
'All', 2, ssq, iarow, iacol,
844 VALUE = ssq( 1 ) * sqrt( ssq( 2 ) )
850 IF( myrow.EQ.iarow .AND. mycol.EQ.iacol )
THEN
851 CALL sgebs2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1 )
853 CALL sgebr2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, iarow,