1 DOUBLE PRECISION FUNCTION pzlanhe( NORM, UPLO, N, A, IA, JA,
15 DOUBLE PRECISION 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 )
169 DOUBLE PRECISION one, zero
170 parameter( one = 1.0d+0, zero = 0.0d+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
177 DOUBLE PRECISION absa, scale, sum, value
180 DOUBLE PRECISION rwork( 2 )
183 EXTERNAL blacs_gridinfo, daxpy,
dcombssq,
184 $ dgamx2d, dgsum2d, dgebr2d,
194 INTRINSIC abs, dble,
max,
min, mod, sqrt
200 ictxt = desca( ctxt_ )
201 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
202 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol,
203 $ iia, jja, iarow, iacol )
205 iroff = mod( ia-1, desca( mb_ ) )
206 icoff = mod( ja-1, desca( nb_ ) )
207 np =
numroc( n+iroff, desca( mb_ ), myrow, iarow, nprow )
208 nq =
numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
212 IF( myrow.EQ.iarow )
THEN
218 IF( mycol.EQ.iacol )
THEN
226 in =
min(
iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+n-1 )
268 ELSE IF(
lsame( norm,
'M' ) )
THEN
274 IF(
lsame( uplo,
'U' ) )
THEN
282 IF( mycol.EQ.iacol )
THEN
283 DO 20 k = (jj-1)*lda, (jj+ib-2)*lda, lda
286 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
302 IF( myrow.EQ.iarow )
THEN
303 DO 40 k = ii, ii+ib-1
304 IF( mycol.EQ.iacol )
THEN
305 IF( jj.LE.jja+nq-1 )
THEN
307 $ abs( dble( a( k+(jj-1)*lda ) ) ) )
308 DO 30 ll = jj*lda, (jja+nq-2)*lda, lda
309 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
313 IF( jj.LE.jja+nq-1 )
THEN
314 DO 35 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
315 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
323 ELSE IF( mycol.EQ.iacol )
THEN
327 icurrow = mod( iarow+1, nprow )
328 icurcol = mod( iacol+1, npcol )
332 DO 90 i = in+1, ia+n-1, desca( mb_ )
333 ib =
min( desca( mb_ ), ia+n-i )
337 IF( mycol.EQ.icurcol )
THEN
338 DO 60 k = (jj-1)*lda, (jj+ib-2)*lda, lda
341 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
344 IF( myrow.EQ.icurrow )
350 IF( myrow.EQ.icurrow )
356 IF( myrow.EQ.icurrow )
THEN
357 DO 80 k = ii, ii+ib-1
358 IF( mycol.EQ.icurcol )
THEN
359 IF( jj.LE.jja+nq-1 )
THEN
361 $ abs( dble( a( k+(jj-1)*lda ) ) ) )
362 DO 70 ll = jj*lda, (jja+nq-2)*lda, lda
363 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
367 IF( jj.LE.jja+nq-1 )
THEN
368 DO 75 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
369 VALUE =
max(
VALUE, abs( a( k+ll ) ) )
373 IF( mycol.EQ.icurcol )
377 ELSE IF( mycol.EQ.icurcol )
THEN
380 icurrow = mod( icurrow+1, nprow )
381 icurcol = mod( icurcol+1, npcol )
392 IF( mycol.EQ.iacol )
THEN
393 DO 110 k = (jj-1)*lda, (jj+ib-2)*lda, lda
394 IF( myrow.EQ.iarow )
THEN
395 IF( ii.LE.iia+np-1 )
THEN
396 VALUE =
max(
VALUE, abs( dble( a( ii+k ) ) ) )
397 DO 100 ll = ii+1, iia+np-1
398 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
402 IF( ii.LE.iia+np-1 )
THEN
403 DO 105 ll = ii, iia+np-1
404 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
420 IF( myrow.EQ.iarow )
THEN
423 DO 120 ll = (jja-1)*lda, (jj-2)*lda, lda
424 VALUE =
max(
VALUE, abs( a( ii+ll ) ) )
431 ELSE IF( mycol.EQ.iacol )
THEN
435 icurrow = mod( iarow+1, nprow )
436 icurcol = mod( iacol+1, npcol )
440 DO 180 i = in+1, ia+n-1, desca( mb_ )
441 ib =
min( desca( mb_ ), ia+n-i )
445 IF( mycol.EQ.icurcol )
THEN
446 DO 150 k = (jj-1)*lda, (jj+ib-2)*lda, lda
447 IF( myrow.EQ.icurrow )
THEN
448 IF( ii.LE.iia+np-1 )
THEN
450 $ abs( dble( a( ii+k ) ) ) )
451 DO 140 ll = ii+1, iia+np-1
452 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
456 IF( ii.LE.iia+np-1 )
THEN
457 DO 145 ll = ii, iia+np-1
458 VALUE =
max(
VALUE, abs( a( ll+k ) ) )
462 IF( myrow.EQ.icurrow )
468 IF( myrow.EQ.icurrow )
474 IF( myrow.EQ.icurrow )
THEN
477 DO 160 ll = (jja-1)*lda, (jj-2)*lda, lda
478 VALUE =
max(
VALUE, abs( a( ii+ll ) ) )
482 IF( mycol.EQ.icurcol )
485 ELSE IF( mycol.EQ.icurcol )
THEN
488 icurrow = mod( icurrow+1, nprow )
489 icurcol = mod( icurcol+1, npcol )
497 CALL dgamx2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, i, k, -1,
500 ELSE IF(
lsame( norm,
'I' ) .OR.
lsame( norm,
'O' ) .OR.
506 IF(
lsame( uplo,
'U' ) )
THEN
514 IF( mycol.EQ.iacol )
THEN
515 ioffa = ( jj - 1 ) * lda
519 DO 190 ll = iia, ii-1
520 sum = sum + abs( a( ll+ioffa ) )
524 work( jj+k-jja+icsr0 ) = sum
538 IF( myrow.EQ.iarow )
THEN
539 DO 220 k = ii, ii+ib-1
541 IF( mycol.EQ.iacol )
THEN
542 IF( jja+nq.GT.jj )
THEN
543 sum = abs( dble( a( k+(jj-1)*lda ) ) )
544 DO 210 ll = jj*lda, (jja+nq-2)*lda, lda
545 sum = sum + abs( a( k+ll ) )
549 IF( jja+nq.GT.jj )
THEN
550 DO 215 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
551 sum = sum + abs( a( k+ll ) )
555 work( k-iia+irsc0 ) = sum
560 ELSE IF( mycol.EQ.iacol )
THEN
564 icurrow = mod( iarow+1, nprow )
565 icurcol = mod( iacol+1, npcol )
569 DO 270 i = in+1, ia+n-1, desca( mb_ )
570 ib =
min( desca( mb_ ), ia+n-i )
574 IF( mycol.EQ.icurcol )
THEN
575 ioffa = ( jj - 1 ) * lda
579 DO 230 ll = iia, ii-1
580 sum = sum + abs( a( ioffa+ll ) )
584 work( jj+k-jja+icsr0 ) = sum
585 IF( myrow.EQ.icurrow )
591 IF( myrow.EQ.icurrow )
598 IF( myrow.EQ.icurrow )
THEN
599 DO 260 k = ii, ii+ib-1
601 IF( mycol.EQ.icurcol )
THEN
602 IF( jja+nq.GT.jj )
THEN
603 sum = abs( dble( a( k+(jj-1)*lda ) ) )
604 DO 250 ll = jj*lda, (jja+nq-2)*lda, lda
605 sum = sum + abs( a( k+ll ) )
609 IF( jja+nq.GT.jj )
THEN
610 DO 255 ll = (jj-1)*lda, (jja+nq-2)*lda, lda
611 sum = sum + abs( a( k+ll ) )
615 work( k-iia+irsc0 ) = sum
616 IF( mycol.EQ.icurcol )
620 ELSE IF( mycol.EQ.icurcol )
THEN
624 icurrow = mod( icurrow+1, nprow )
625 icurcol = mod( icurcol+1, npcol )
637 IF( mycol.EQ.iacol )
THEN
641 IF( myrow.EQ.iarow )
THEN
642 IF( iia+np.GT.ii )
THEN
643 sum = abs( dble( a( ioffa+ii ) ) )
644 DO 280 ll = ii+1, iia+np-1
645 sum = sum + abs( a( ioffa+ll ) )
649 DO 285 ll = ii, iia+np-1
650 sum = sum + abs( a( ioffa+ll ) )
654 work( jj+k-jja+icsr0 ) = sum
668 IF( myrow.EQ.iarow )
THEN
669 DO 310 k = ii, ii+ib-1
672 DO 300 ll = (jja-1)*lda, (jj-2)*lda, lda
673 sum = sum + abs( a( k+ll ) )
676 work( k-iia+irsc0 ) = sum
681 ELSE IF( mycol.EQ.iacol )
THEN
685 icurrow = mod( iarow+1, nprow )
686 icurcol = mod( iacol+1, npcol )
690 DO 360 i = in+1, ia+n-1, desca( mb_ )
691 ib =
min( desca( mb_ ), ia+n-i )
695 IF( mycol.EQ.icurcol )
THEN
696 ioffa = ( jj - 1 ) * lda
699 IF( myrow.EQ.icurrow )
THEN
700 IF( iia+np.GT.ii )
THEN
701 sum = abs( dble( a( ii+ioffa ) ) )
702 DO 320 ll = ii+1, iia+np-1
703 sum = sum + abs( a( ll+ioffa ) )
705 ELSE IF( ii.EQ.iia+np-1 )
THEN
706 sum = abs( dble( a( ii+ioffa ) ) )
709 DO 325 ll = ii, iia+np-1
710 sum = sum + abs( a( ll+ioffa ) )
714 work( jj+k-jja+icsr0 ) = sum
715 IF( myrow.EQ.icurrow )
721 IF( myrow.EQ.icurrow )
728 IF( myrow.EQ.icurrow )
THEN
729 DO 350 k = ii, ii+ib-1
732 DO 340 ll = (jja-1)*lda, (jj-2)*lda, lda
733 sum = sum + abs( a( k+ll ) )
736 work(k-iia+irsc0) = sum
737 IF( mycol.EQ.icurcol )
741 ELSE IF( mycol.EQ.icurcol )
THEN
745 icurrow = mod( icurrow+1, nprow )
746 icurcol = mod( icurcol+1, npcol )
758 CALL dgsum2d( ictxt,
'Columnwise',
' ', 1, nq, work( icsr ), 1,
762 CALL dgsum2d( ictxt,
'Rowwise',
' ', np, 1, work( irsc ),
763 $
max( 1, np ), myrow, iacol )
765 CALL pdcol2row( ictxt, n, 1, desca( mb_ ), work( irsc ),
766 $
max( 1, np ), work( irsr ),
max( 1, nq ),
767 $ iarow, iacol, iarow, iacol, work( irsc+np ) )
769 IF( myrow.EQ.iarow )
THEN
772 CALL daxpy( nq, one, work( irsr0 ), 1, work( icsr0 ), 1 )
776 VALUE = work( idamax( nq, work( icsr0 ), 1 ) )
778 CALL dgamx2d( ictxt,
'Rowwise',
' ', 1, 1,
VALUE, 1, i, k,
782 ELSE IF(
lsame( norm,
'F' ) .OR.
lsame( norm,
'E' ) )
THEN
791 IF(
lsame( uplo,
'U' ) )
THEN
797 IF( mycol.EQ.iacol )
THEN
798 DO 370 k = (jj-1)*lda, (jj+ib-2)*lda, lda
799 CALL zlassq( ii-iia, a( iia+k ), 1, scale, sum )
800 CALL zlassq( ii-iia, a( iia+k ), 1, scale, sum )
801 IF( myrow.EQ.iarow )
THEN
802 IF( dble( a( ii+k ) ).NE.zero )
THEN
803 absa = abs( dble( a( ii+k ) ) )
804 IF( scale.LT.absa )
THEN
805 sum = one + sum * ( scale / absa )**2
808 sum = sum + ( absa / scale )**2
816 ELSE IF( myrow.EQ.iarow )
THEN
820 icurrow = mod( iarow+1, nprow )
821 icurcol = mod( iacol+1, npcol )
825 DO 390 i = in+1, ia+n-1, desca( mb_ )
826 ib =
min( desca( mb_ ), ia+n-i )
828 IF( mycol.EQ.icurcol )
THEN
829 DO 380 k = (jj-1)*lda, (jj+ib-2)*lda, lda
830 CALL zlassq( ii-iia, a( iia+k ), 1, scale, sum )
831 CALL zlassq( ii-iia, a( iia+k ), 1, scale, sum )
832 IF( myrow.EQ.icurrow )
THEN
833 IF( dble( a( ii+k ) ).NE.zero )
THEN
834 absa = abs( dble( a( ii+k ) ) )
835 IF( scale.LT.absa )
THEN
836 sum = one + sum * ( scale / absa )**2
839 sum = sum + ( absa / scale )**2
847 ELSE IF( myrow.EQ.icurrow )
THEN
851 icurrow = mod( icurrow+1, nprow )
852 icurcol = mod( icurcol+1, npcol )
862 IF( mycol.EQ.iacol )
THEN
863 DO 400 k = (jj-1)*lda, (jj+ib-2)*lda, lda
864 IF( myrow.EQ.iarow )
THEN
865 IF( dble( a( ii+k ) ).NE.zero )
THEN
866 absa = abs( dble( a( ii+k ) ) )
867 IF( scale.LT.absa )
THEN
868 sum = one + sum * ( scale / absa )**2
871 sum = sum + ( absa / scale )**2
876 CALL zlassq( iia+np-ii, a( ii+k ), 1, scale, sum )
877 CALL zlassq( iia+np-ii, a( ii+k ), 1, scale, sum )
881 ELSE IF( myrow.EQ.iarow )
THEN
885 icurrow = mod( iarow+1, nprow )
886 icurcol = mod( iacol+1, npcol )
890 DO 420 i = in+1, ia+n-1, desca( mb_ )
891 ib =
min( desca( mb_ ), ia+n-i )
893 IF( mycol.EQ.icurcol )
THEN
894 DO 410 k = (jj-1)*lda, (jj+ib-2)*lda, lda
895 IF( myrow.EQ.icurrow )
THEN
896 IF( dble( a( ii+k ) ).NE.zero )
THEN
897 absa = abs( dble( a( ii+k ) ) )
898 IF( scale.LT.absa )
THEN
899 sum = one + sum * ( scale / absa )**2
902 sum = sum + ( absa / scale )**2
907 CALL zlassq( iia+np-ii, a( ii+k ), 1, scale, sum )
908 CALL zlassq( iia+np-ii, a( ii+k ), 1, scale, sum )
912 ELSE IF( myrow.EQ.icurrow )
THEN
916 icurrow = mod( icurrow+1, nprow )
917 icurcol = mod( icurcol+1, npcol )
928 CALL pdtreecomb( ictxt,
'All', 2, rwork, iarow, iacol,
930 VALUE = rwork( 1 ) * sqrt( rwork( 2 ) )
936 IF( myrow.EQ.iarow .AND. mycol.EQ.iacol )
THEN
937 CALL dgebs2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1 )
939 CALL dgebr2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, iarow,