1 DOUBLE PRECISION FUNCTION pdlantr( NORM, UPLO, DIAG, M, N, A,
2 $ IA, JA, DESCA, WORK )
11 CHARACTER diag, norm, uplo
16 DOUBLE PRECISION a( * ), work( * )
163 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dtype_,
164 $ lld_, mb_, m_, nb_, n_, rsrc_
165 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
166 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
167 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
168 DOUBLE PRECISION one, zero
169 parameter( one = 1.0d+0, zero = 0.0d+0 )
173 INTEGER iacol, iarow, ictxt, ii, iia, icoff, ioffa,
174 $ iroff, j, jb, jj, jja, jn, kk, lda, ll, mp,
175 $ mycol, myrow, np, npcol, nprow, nq
176 DOUBLE PRECISION sum, value
179 DOUBLE PRECISION ssq( 2 ), colssq( 2 )
182 EXTERNAL blacs_gridinfo,
dcombssq, dgebr2d,
183 $ dgebs2d, dgamx2d, dgsum2d, dlassq,
192 INTRINSIC abs, dble,
max,
min, mod, sqrt
198 ictxt = desca( ctxt_ )
199 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
201 udiag =
lsame( diag,
'U' )
202 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
204 iroff = mod( ia-1, desca( mb_ ) )
205 icoff = mod( ja-1, desca( nb_ ) )
206 mp =
numroc( m+iroff, desca( mb_ ), myrow, iarow, nprow )
207 nq =
numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
213 ioffa = ( jja - 1 ) * lda
215 IF(
min( m, n ).EQ.0 )
THEN
222 ELSE IF(
lsame( norm,
'M' ) )
THEN
232 IF(
lsame( uplo,
'U' ) )
THEN
238 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
241 IF( mycol.EQ.iacol )
THEN
242 IF( myrow.EQ.iarow )
THEN
244 DO 20 ll = jj, jj + jb -1
245 DO 10 kk = iia,
min(ii+ll-jj-1,iia+mp-1)
246 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
251 DO 40 ll = jj, jj + jb -1
252 DO 30 kk = iia,
min( ii+ll-jj, iia+mp-1 )
253 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
259 DO 60 ll = jj, jj + jb -1
260 DO 50 kk = iia,
min( ii-1, iia+mp-1 )
261 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
271 iarow = mod( iarow+1, nprow )
272 iacol = mod( iacol+1, npcol )
276 DO 130 j = jn+1, ja+n-1, desca( nb_ )
277 jb =
min( ja+n-j, desca( nb_ ) )
279 IF( mycol.EQ.iacol )
THEN
280 IF( myrow.EQ.iarow )
THEN
282 DO 80 ll = jj, jj + jb -1
283 DO 70 kk = iia,
min( ii+ll-jj-1, iia+mp-1 )
284 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
289 DO 100 ll = jj, jj + jb -1
290 DO 90 kk = iia,
min( ii+ll-jj, iia+mp-1 )
291 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
297 DO 120 ll = jj, jj + jb -1
298 DO 110 kk = iia,
min( ii-1, iia+mp-1 )
299 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
309 iarow = mod( iarow+1, nprow )
310 iacol = mod( iacol+1, npcol )
320 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
323 IF( mycol.EQ.iacol )
THEN
324 IF( myrow.EQ.iarow )
THEN
326 DO 150 ll = jj, jj + jb -1
327 DO 140 kk = ii+ll-jj+1, iia+mp-1
328 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
333 DO 170 ll = jj, jj + jb -1
334 DO 160 kk = ii+ll-jj, iia+mp-1
335 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
341 DO 190 ll = jj, jj + jb -1
342 DO 180 kk = ii, iia+mp-1
343 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
353 iarow = mod( iarow+1, nprow )
354 iacol = mod( iacol+1, npcol )
358 DO 260 j = jn+1, ja+n-1, desca( nb_ )
359 jb =
min( ja+n-j, desca( nb_ ) )
361 IF( mycol.EQ.iacol )
THEN
362 IF( myrow.EQ.iarow )
THEN
364 DO 210 ll = jj, jj + jb -1
365 DO 200 kk = ii+ll-jj+1, iia+mp-1
366 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
371 DO 230 ll = jj, jj + jb -1
372 DO 220 kk = ii+ll-jj, iia+mp-1
373 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
379 DO 250 ll = jj, jj + jb -1
380 DO 240 kk = ii, iia+mp-1
381 VALUE =
max(
VALUE, abs( a( ioffa+kk ) ) )
391 iarow = mod( iarow+1, nprow )
392 iacol = mod( iacol+1, npcol )
400 CALL dgamx2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, kk, ll, -1,
406 ELSE IF(
lsame( norm,
'O' ) .OR. norm.EQ.
'1' )
THEN
410 IF(
lsame( uplo,
'U' ) )
THEN
416 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
419 IF( mycol.EQ.iacol )
THEN
420 IF( myrow.EQ.iarow )
THEN
422 DO 280 ll = jj, jj + jb -1
424 DO 270 kk = iia,
min( ii+ll-jj-1, iia+mp-1 )
425 sum = sum + abs( a( ioffa+kk ) )
429 IF (kk <= iia+mp-1)
THEN
433 work( ll-jja+1 ) = sum
436 DO 300 ll = jj, jj + jb -1
438 DO 290 kk = iia,
min( ii+ll-jj, iia+mp-1 )
439 sum = sum + abs( a( ioffa+kk ) )
442 work( ll-jja+1 ) = sum
446 DO 320 ll = jj, jj + jb -1
448 DO 310 kk = iia,
min( ii-1, iia+mp-1 )
449 sum = sum + abs( a( ioffa+kk ) )
452 work( ll-jja+1 ) = sum
460 iarow = mod( iarow+1, nprow )
461 iacol = mod( iacol+1, npcol )
465 DO 390 j = jn+1, ja+n-1, desca( nb_ )
466 jb =
min( ja+n-j, desca( nb_ ) )
468 IF( mycol.EQ.iacol )
THEN
469 IF( myrow.EQ.iarow )
THEN
471 DO 340 ll = jj, jj + jb -1
473 DO 330 kk = iia,
min( ii+ll-jj-1, iia+mp-1 )
474 sum = sum + abs( a( ioffa+kk ) )
478 IF (kk <= iia+mp-1)
THEN
482 work( ll-jja+1 ) = sum
485 DO 360 ll = jj, jj + jb -1
487 DO 350 kk = iia,
min( ii+ll-jj, iia+mp-1 )
488 sum = sum + abs( a( ioffa+kk ) )
491 work( ll-jja+1 ) = sum
495 DO 380 ll = jj, jj + jb -1
497 DO 370 kk = iia,
min( ii-1, iia+mp-1 )
498 sum = sum + abs( a( ioffa+kk ) )
501 work( ll-jja+1 ) = sum
509 iarow = mod( iarow+1, nprow )
510 iacol = mod( iacol+1, npcol )
520 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
523 IF( mycol.EQ.iacol )
THEN
524 IF( myrow.EQ.iarow )
THEN
526 DO 410 ll = jj, jj + jb -1
528 DO 400 kk = ii+ll-jj+1, iia+mp-1
529 sum = sum + abs( a( ioffa+kk ) )
532 work( ll-jja+1 ) = sum
535 DO 430 ll = jj, jj + jb -1
537 DO 420 kk = ii+ll-jj, iia+mp-1
538 sum = sum + abs( a( ioffa+kk ) )
541 work( ll-jja+1 ) = sum
545 DO 450 ll = jj, jj + jb -1
547 DO 440 kk = ii, iia+mp-1
548 sum = sum + abs( a( ioffa+kk ) )
551 work( ll-jja+1 ) = sum
559 iarow = mod( iarow+1, nprow )
560 iacol = mod( iacol+1, npcol )
564 DO 520 j = jn+1, ja+n-1, desca( nb_ )
565 jb =
min( ja+n-j, desca( nb_ ) )
567 IF( mycol.EQ.iacol )
THEN
568 IF( myrow.EQ.iarow )
THEN
570 DO 470 ll = jj, jj + jb -1
572 DO 460 kk = ii+ll-jj+1, iia+mp-1
573 sum = sum + abs( a( ioffa+kk ) )
576 work( ll-jja+1 ) = sum
579 DO 490 ll = jj, jj + jb -1
581 DO 480 kk = ii+ll-jj, iia+mp-1
582 sum = sum + abs( a( ioffa+kk ) )
585 work( ll-jja+1 ) = sum
589 DO 510 ll = jj, jj + jb -1
591 DO 500 kk = ii, iia+mp-1
592 sum = sum + abs( a( ioffa+kk ) )
595 work( ll-jja+1 ) = sum
603 iarow = mod( iarow+1, nprow )
604 iacol = mod( iacol+1, npcol )
613 CALL dgsum2d( ictxt,
'Columnwise',
' ', 1, nq, work, 1,
618 IF( myrow.EQ.0 )
THEN
620 VALUE = work( idamax( nq, work, 1 ) )
624 CALL dgamx2d( ictxt,
'Rowwise',
' ', 1, 1,
VALUE, 1, kk, ll,
631 ELSE IF(
lsame( norm,
'I' ) )
THEN
633 IF(
lsame( uplo,
'U' ) )
THEN
634 DO 540 kk = iia, iia+mp-1
638 DO 570 kk = iia, iia+mp-1
643 IF(
lsame( uplo,
'U' ) )
THEN
649 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
652 IF( mycol.EQ.iacol )
THEN
653 IF( myrow.EQ.iarow )
THEN
655 DO 590 ll = jj, jj + jb -1
656 DO 580 kk = iia,
min( ii+ll-jj-1, iia+mp-1 )
657 work( kk-iia+1 ) = work( kk-iia+1 ) +
658 $ abs( a( ioffa+kk ) )
662 IF (kk <= iia+mp-1)
THEN
663 work( kk-iia+1 ) = work( kk-iia+1 ) + one
668 DO 610 ll = jj, jj + jb -1
669 DO 600 kk = iia,
min( ii+ll-jj, iia+mp-1 )
670 work( kk-iia+1 ) = work( kk-iia+1 ) +
671 $ abs( a( ioffa+kk ) )
677 DO 630 ll = jj, jj + jb -1
678 DO 620 kk = iia,
min( ii-1, iia+mp-1 )
679 work( kk-iia+1 ) = work( kk-iia+1 ) +
680 $ abs( a( ioffa+kk ) )
690 iarow = mod( iarow+1, nprow )
691 iacol = mod( iacol+1, npcol )
695 DO 700 j = jn+1, ja+n-1, desca( nb_ )
696 jb =
min( ja+n-j, desca( nb_ ) )
698 IF( mycol.EQ.iacol )
THEN
699 IF( myrow.EQ.iarow )
THEN
701 DO 650 ll = jj, jj + jb -1
702 DO 640 kk = iia,
min( ii+ll-jj-1, iia+mp-1 )
703 work( kk-iia+1 ) = work( kk-iia+1 ) +
704 $ abs( a( ioffa+kk ) )
708 IF (kk <= iia+mp-1)
THEN
709 work( kk-iia+1 ) = work( kk-iia+1 ) + one
714 DO 670 ll = jj, jj + jb -1
715 DO 660 kk = iia,
min( ii+ll-jj, iia+mp-1 )
716 work( kk-iia+1 ) = work( kk-iia+1 ) +
717 $ abs( a( ioffa+kk ) )
723 DO 690 ll = jj, jj + jb -1
724 DO 680 kk = iia,
min( ii-1, iia+mp-1 )
725 work( kk-iia+1 ) = work( kk-iia+1 ) +
726 $ abs( a( ioffa+kk ) )
736 iarow = mod( iarow+1, nprow )
737 iacol = mod( iacol+1, npcol )
747 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
750 IF( mycol.EQ.iacol )
THEN
751 IF( myrow.EQ.iarow )
THEN
753 DO 720 ll = jj, jj + jb -1
756 work( kk-iia+1 ) = work( kk-iia+1 ) + one
757 DO 710 kk = ii+ll-jj+1, iia+mp-1
758 work( kk-iia+1 ) = work( kk-iia+1 ) +
759 $ abs( a( ioffa+kk ) )
764 DO 740 ll = jj, jj + jb -1
765 DO 730 kk = ii+ll-jj, iia+mp-1
766 work( kk-iia+1 ) = work( kk-iia+1 ) +
767 $ abs( a( ioffa+kk ) )
773 DO 760 ll = jj, jj + jb -1
774 DO 750 kk = ii, iia+mp-1
775 work( kk-iia+1 ) = work( kk-iia+1 ) +
776 $ abs( a( ioffa+kk ) )
786 iarow = mod( iarow+1, nprow )
787 iacol = mod( iacol+1, npcol )
791 DO 830 j = jn+1, ja+n-1, desca( nb_ )
792 jb =
min( ja+n-j, desca( nb_ ) )
794 IF( mycol.EQ.iacol )
THEN
795 IF( myrow.EQ.iarow )
THEN
797 DO 780 ll = jj, jj + jb -1
800 work( kk-iia+1 ) = work( kk-iia+1 ) + one
801 DO 770 kk = ii+ll-jj+1, iia+mp-1
802 work( kk-iia+1 ) = work( kk-iia+1 ) +
803 $ abs( a( ioffa+kk ) )
808 DO 800 ll = jj, jj + jb -1
809 DO 790 kk = ii+ll-jj, iia+mp-1
810 work( kk-iia+1 ) = work( kk-iia+1 ) +
811 $ abs( a( ioffa+kk ) )
817 DO 820 ll = jj, jj + jb -1
818 DO 810 kk = ii, iia+mp-1
819 work( kk-iia+1 ) = work( kk-iia+1 ) +
820 $ abs( a( ioffa+kk ) )
830 iarow = mod( iarow+1, nprow )
831 iacol = mod( iacol+1, npcol )
840 CALL dgsum2d( ictxt,
'Rowwise',
' ', mp, 1, work,
max( 1, mp ),
845 IF( mycol.EQ.0 )
THEN
847 VALUE = work( idamax( mp, work, 1 ) )
851 CALL dgamx2d( ictxt,
'Columnwise',
' ', 1, 1,
VALUE, 1, kk,
860 ELSE IF(
lsame( norm,
'F' ) .OR.
lsame( norm,
'E' ) )
THEN
864 ssq(2) = dble(
min( m, n ) ) / dble( nprow*npcol )
870 IF(
lsame( uplo,
'U' ) )
THEN
877 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
882 IF( mycol.EQ.iacol )
THEN
883 IF( myrow.EQ.iarow )
THEN
887 DO 840 ll = jj, jj + jb -1
890 CALL dlassq(
min( ii+ll-jj-1, iia+mp-1 )-iia+1,
892 $ colssq(1), colssq(2) )
897 DO 850 ll = jj, jj + jb -1
900 CALL dlassq(
min( ii+ll-jj, iia+mp-1 )-iia+1,
902 $ colssq(1), colssq(2) )
911 DO 860 ll = jj, jj + jb -1
914 CALL dlassq(
min( ii-1, iia+mp-1 )-iia+1,
916 $ colssq(1), colssq(2) )
929 iarow = mod( iarow+1, nprow )
930 iacol = mod( iacol+1, npcol )
934 DO 900 j = jn+1, ja+n-1, desca( nb_ )
935 jb =
min( ja+n-j, desca( nb_ ) )
937 IF( mycol.EQ.iacol )
THEN
938 IF( myrow.EQ.iarow )
THEN
940 DO 870 ll = jj, jj + jb -1
943 CALL dlassq(
min(ii+ll-jj-1, iia+mp-1)-iia+1,
945 $ colssq(1), colssq(2) )
950 DO 880 ll = jj, jj + jb -1
953 CALL dlassq(
min( ii+ll-jj, iia+mp-1 )-iia+1,
955 $ colssq(1), colssq(2) )
961 DO 890 ll = jj, jj + jb -1
964 CALL dlassq(
min( ii-1, iia+mp-1 )-iia+1,
966 $ colssq(1), colssq(2) )
976 iarow = mod( iarow+1, nprow )
977 iacol = mod( iacol+1, npcol )
988 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
991 IF( mycol.EQ.iacol )
THEN
992 IF( myrow.EQ.iarow )
THEN
994 DO 910 ll = jj, jj + jb -1
997 CALL dlassq( iia+mp-(ii+ll-jj+1),
998 $ a( ii+ll-jj+1+ioffa ), 1,
999 $ colssq(1), colssq(2) )
1004 DO 920 ll = jj, jj + jb -1
1007 CALL dlassq( iia+mp-(ii+ll-jj),
1008 $ a( ii+ll-jj+ioffa ), 1,
1009 $ colssq(1), colssq(2) )
1015 DO 930 ll = jj, jj + jb -1
1018 CALL dlassq( iia+mp-ii, a( ii+ioffa ), 1,
1019 $ colssq(1), colssq(2) )
1027 IF( myrow.EQ.iarow )
1029 iarow = mod( iarow+1, nprow )
1030 iacol = mod( iacol+1, npcol )
1034 DO 970 j = jn+1, ja+n-1, desca( nb_ )
1035 jb =
min( ja+n-j, desca( nb_ ) )
1037 IF( mycol.EQ.iacol )
THEN
1038 IF( myrow.EQ.iarow )
THEN
1040 DO 940 ll = jj, jj + jb -1
1043 CALL dlassq( iia+mp-(ii+ll-jj+1),
1044 $ a( ii+ll-jj+1+ioffa ), 1,
1045 $ colssq(1), colssq(2) )
1050 DO 950 ll = jj, jj + jb -1
1053 CALL dlassq( iia+mp-(ii+ll-jj),
1054 $ a( ii+ll-jj+ioffa ), 1,
1055 $ colssq(1), colssq(2) )
1061 DO 960 ll = jj, jj + jb -1
1064 CALL dlassq( iia+mp-ii, a( ii+ioffa ), 1,
1065 $ colssq(1), colssq(2) )
1073 IF( myrow.EQ.iarow )
1075 iarow = mod( iarow+1, nprow )
1076 iacol = mod( iacol+1, npcol )
1086 VALUE = ssq( 1 ) * sqrt( ssq( 2 ) )
1092 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
1093 CALL dgebs2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1 )
1095 CALL dgebr2d( ictxt,
'All',
' ', 1, 1,
VALUE, 1, 0, 0 )