Routine: PDLAQSY()  File: SRC\pdlaqsy.f

 
 
# lines: 359
  # code: 359
  # comment: 0
  # blank:0
# Variables:48
# Callers:1
# Callings:1
# Words:151
# Keywords:107
 

 

..
     .. Array Arguments ..
     ..
  Purpose
  =======
  PDLAQSY equilibrates a symmetric distributed matrix
  sub( A ) = A(IA:IA+N-1,JA:JA+N-1) using the scaling factors in the
  vectors SR and SC.
  Notes
  =====
  Each global data object is described by an associated description
  vector.  This vector stores the information required to establish
  the mapping between an object element and its corresponding process
  and memory location.
  Let A be a generic term for any 2D block cyclicly distributed array.
  Such a global array has an associated description vector DESCA.
  In the following comments, the character _ should be read as
  "of the global array".
  NOTATION        STORED IN      EXPLANATION
  --------------- -------------- --------------------------------------
  DTYPE_A(global) DESCA( DTYPE_ )The descriptor type.  In this case,
                                 DTYPE_A = 1.
  CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
                                 the BLACS process grid A is distribu-
                                 ted over. The context itself is glo-
                                 bal, but the handle (the integer
                                 value) may vary.
  M_A    (global) DESCA( M_ )    The number of rows in the global
                                 array A.
  N_A    (global) DESCA( N_ )    The number of columns in the global
                                 array A.
  MB_A   (global) DESCA( MB_ )   The blocking factor used to distribute
                                 the rows of the array.
  NB_A   (global) DESCA( NB_ )   The blocking factor used to distribute
                                 the columns of the array.
  RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
                                 row of the array A is distributed.
  CSRC_A (global) DESCA( CSRC_ ) The process column over which the
                                 first column of the array A is
                                 distributed.
  LLD_A  (local)  DESCA( LLD_ )  The leading dimension of the local
                                 array.  LLD_A >= MAX(1,LOCr(M_A)).
  Let K be the number of rows or columns of a distributed matrix,
  and assume that its process grid has dimension p x q.
  LOCr( K ) denotes the number of elements of K that a process
  would receive if K were distributed over the p processes of its
  process column.
  Similarly, LOCc( K ) denotes the number of elements of K that a
  process would receive if K were distributed over the q processes of
  its process row.
  The values of LOCr() and LOCc() may be determined via a call to the
  ScaLAPACK tool function, NUMROC:
          LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
          LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
  An upper bound for these quantities may be computed by:
          LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
          LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
  Arguments
  =========
  UPLO    (global input) CHARACTER
          Specifies whether the upper or lower triangular part of the
          symmetric distributed matrix sub( A ) is to be referenced:
             = 'U':  Upper triangular
             = 'L':  Lower triangular
  N       (global input) INTEGER
          The number of rows and columns to be operated on, i.e. the
          order of the distributed submatrix sub( A ). N >= 0.
  A       (input/output) DOUBLE PRECISION pointer into the local
          memory to an array of local dimension (LLD_A,LOCc(JA+N-1)).
          On entry, the local pieces of the distributed symmetric
          matrix sub( A ). If UPLO = 'U', the leading N-by-N upper
          triangular part of sub( A ) contains the upper triangular
          part of the matrix, and the strictly lower triangular part
          of sub( A ) is not referenced.  If UPLO = 'L', the leading
          N-by-N lower triangular part of sub( A ) contains the lower
          triangular part of the matrix, and the strictly upper trian-
          gular part of sub( A ) is not referenced.
          On exit, if EQUED = 'Y', the equilibrated matrix:
              diag(SR(IA:IA+N-1)) * sub( A ) * diag(SC(JA:JA+N-1)).
  IA      (global input) INTEGER
          The row index in the global array A indicating the first
          row of sub( A ).
  JA      (global input) INTEGER
          The column index in the global array A indicating the
          first column of sub( A ).
  DESCA   (global and local input) INTEGER array of dimension DLEN_.
          The array descriptor for the distributed matrix A.
  SR      (local input) DOUBLE PRECISION array, dimension LOCr(M_A)
          The scale factors for A(IA:IA+M-1,JA:JA+N-1). SR is aligned
          with the distributed matrix A, and replicated across every
          process column. SR is tied to the distributed matrix A.
  SC      (local input) DOUBLE PRECISION array, dimension LOCc(N_A)
          The scale factors for sub( A ). SC is aligned with the dis-
          tributed matrix A, and replicated down every process row.
          SC is tied to the distributed matrix A.
  SCOND   (global input) DOUBLE PRECISION
          Ratio of the smallest SR(i) (respectively SC(j)) to the
          largest SR(i) (respectively SC(j)), with IA <= i <= IA+N-1
          and JA <= j <= JA+N-1.
  AMAX    (global input) DOUBLE PRECISION
          Absolute value of the largest distributed submatrix entry.
  EQUED   (output) CHARACTER*1
          Specifies whether or not equilibration was done.
          = 'N':  No equilibration.
          = 'Y':  Equilibration was done, i.e., sub( A ) has been re-
                  placed by:
                  diag(SR(IA:IA+N-1)) * sub( A ) * diag(SC(JA:JA+N-1)).
  Internal Parameters
  ===================
  THRESH is a threshold value used to decide if scaling should be done
  based on the ratio of the scaling factors.  If SCOND < THRESH,
  scaling is done.
  LARGE and SMALL are threshold values used to decide if scaling should
  be done based on the absolute size of the largest matrix element.
  If AMAX > LARGE or AMAX < SMALL, scaling is done.
  =====================================================================
     .. Parameters ..

 
Display dynamic version Find AutoScroll Reload FontSize: - + Hide Comments Hide Blanks Frame FullScreen MailPrint

 
001        SUBROUTINE PDLAQSY( UPLO , N , A , IA , JA , DESCA , SR , SC , SCOND ,
002       $AMAX , EQUED )
003  
004  *     -- ScaLAPACK auxiliary routine(version 1.7) --
005  *     University of Tennessee , Knoxville , Oak Ridge National Laboratory ,
006  *     and University of California , Berkeley.
007  *     May 1 , 1997
008  
009  *     .. Scalar Arguments ..
010        CHARACTER EQUED , UPLO
011        INTEGER IA , JA , N
012        DOUBLE PRECISION AMAX , SCOND
013        INTEGER BLOCK_CYCLIC_2D , CSRC_ , CTXT_ , DLEN_ , DTYPE_ ,
014       $LLD_ , MB_ , M_ , NB_ , N_ , RSRC_
015        PARAMETER( BLOCK_CYCLIC_2D = 1 , DLEN_ = 9 , DTYPE_ = 1 ,
016       $CTXT_ = 2 , M_ = 3 , N_ = 4 , MB_ = 5 , NB_ = 6 ,
017       $RSRC_ = 7 , CSRC_ = 8 , LLD_ = 9 )
018        DOUBLE PRECISION ONE , THRESH
019        PARAMETER( ONE = 1.0D + 0 , THRESH = 0.1D + 0 )
020  *     ..
021  *     .. Local Scalars ..
022        INTEGER IACOL , IAROW , ICTXT , II , IIA , IOFFA , IROFF , J ,
023       $JB , JJ , JJA , JN , KK , LDA , LL , MYCOL , MYROW , NP ,
024       $NPCOL , NPROW
025        DOUBLE PRECISION CJ , LARGE , SMALL
026  *     ..
027  *     .. External Subroutines ..
028        EXTERNAL BLACS_GRIDINFO , INFOG2L
029  *     ..
030  *     .. External Functions ..
031        LOGICAL LSAME
032        INTEGER ICEIL , NUMROC
033        DOUBLE PRECISION PDLAMCH
034        EXTERNAL ICEIL , LSAME , NUMROC , PDLAMCH
035  *     ..
036  *     .. Intrinsic Functions ..
037        INTRINSIC MIN , MOD
038  *     ..
039  *     .. Executable Statements ..
040  
041  *     Quick return if possible
042  
043        IF( N.LE.0 ) THEN
044            EQUED = 'N'
045            RETURN
046        END IF
047  
048  *     Get grid parameters and compute local indexes
049  
050        ICTXT = DESCA( CTXT_ )
051        CALL BLACS_GRIDINFO( ICTXT , NPROW , NPCOL , MYROW , MYCOL )
052        CALL INFOG2L( IA , JA , DESCA , NPROW , NPCOL , MYROW , MYCOL , IIA , JJA ,
053       $IAROW , IACOL )
054        LDA = DESCA( LLD_ )
055  
056  *     Initialize LARGE and SMALL.
057  
058        SMALL = PDLAMCH( ICTXT , 'Safe minimum' ) /
059       $PDLAMCH( ICTXT , 'Precision' )
060        LARGE = ONE / SMALL
061  
062        IF( SCOND.GE.THRESH .AND. AMAX.GE.SMALL .AND. AMAX.LE.LARGE ) THEN
063  
064  *         No equilibration
065  
066            EQUED = 'N'
067  
068        ELSE
069  
070            II = IIA
071            JJ = JJA
072            JN = MIN( ICEIL( JA , DESCA( NB_ ) ) * DESCA( NB_ ) , JA + N - 1 )
073            JB = JN - JA + 1
074  
075  *         Replace A by diag(S) * A * diag(S).
076  
077            IF( LSAME( UPLO , 'U' ) ) THEN
078  
079  *             Upper triangle of A(IA : IA + N - 1 , JA : JA + N - 1) is stored.
080  *             Handle first block separately
081  
082                IOFFA =(JJ - 1)*LDA
083                IF( MYCOL.EQ.IACOL ) THEN
084                    IF( MYROW.EQ.IAROW ) THEN
085                        DO 20 LL = JJ , JJ + JB - 1
086                            CJ = SC( LL )
087                            DO 10 KK = IIA , II + LL - JJ + 1
088                                A( IOFFA + KK ) = CJ*SR( KK )*A( IOFFA + KK )
089     10                     CONTINUE
090                            IOFFA = IOFFA + LDA
091     20                 CONTINUE
092                    ELSE
093                        IOFFA = IOFFA + JB*LDA
094                    END IF
095                    JJ = JJ + JB
096                END IF
097  
098                IF( MYROW.EQ.IAROW )
099       $            II = II + JB
100                    IAROW = MOD( IAROW + 1 , NPROW )
101                    IACOL = MOD( IACOL + 1 , NPCOL )
102  
103  *                 Loop over remaining block of columns
104  
105                    DO 70 J = JN + 1 , JA + N - 1 , DESCA( NB_ )
106                        JB = MIN( JA + N - J , DESCA( NB_ ) )
107  
108                        IF( MYCOL.EQ.IACOL ) THEN
109                            IF( MYROW.EQ.IAROW ) THEN
110                                DO 40 LL = JJ , JJ + JB - 1
111                                    CJ = SC( LL )
112                                    DO 30 KK = IIA , II + LL - JJ + 1
113                                        A( IOFFA + KK ) = CJ*SR( KK )*A( IOFFA + KK )
114     30                             CONTINUE
115                                    IOFFA = IOFFA + LDA
116     40                         CONTINUE
117                            ELSE
118                                DO 60 LL = JJ , JJ + JB - 1
119                                    CJ = SC( LL )
120                                    DO 50 KK = IIA , II - 1
121                                        A( IOFFA + KK ) = CJ*SR( KK )*A( IOFFA + KK )
122     50                             CONTINUE
123                                    IOFFA = IOFFA + LDA
124     60                         CONTINUE
125                            END IF
126                            JJ = JJ + JB
127                        END IF
128  
129                        IF( MYROW.EQ.IAROW )
130       $                    II = II + JB
131                            IAROW = MOD( IAROW + 1 , NPROW )
132                            IACOL = MOD( IACOL + 1 , NPCOL )
133  
134     70             CONTINUE
135  
136                ELSE
137  
138  *                 Lower triangle of A(IA : IA + N - 1 , JA : JA + N - 1) is stored.
139  *                 Handle first block separately
140  
141                    IROFF = MOD( IA - 1 , DESCA( MB_ ) )
142                    NP = NUMROC( N + IROFF , DESCA( MB_ ) , MYROW , IAROW , NPROW )
143                    IF( MYROW.EQ.IAROW )
144       $                NP = NP - IROFF
145  
146                        IOFFA =(JJ - 1)*LDA
147                        IF( MYCOL.EQ.IACOL ) THEN
148                            IF( MYROW.EQ.IAROW ) THEN
149                                DO 90 LL = JJ , JJ + JB - 1
150                                    CJ = SC( LL )
151                                    DO 80 KK = II + LL - JJ , IIA + NP - 1
152                                        A( IOFFA + KK ) = CJ*SR( KK )*A( IOFFA + KK )
153     80                             CONTINUE
154                                    IOFFA = IOFFA + LDA
155     90                         CONTINUE
156                            ELSE
157                                DO 110 LL = JJ , JJ + JB - 1
158                                    CJ = SC( LL )
159                                    DO 100 KK = II , IIA + NP - 1
160                                        A( IOFFA + KK ) = CJ*SR( KK )*A( IOFFA + KK )
161    100                             CONTINUE
162                                    IOFFA = IOFFA + LDA
163    110                         CONTINUE
164                            END IF
165                            JJ = JJ + JB
166                        END IF
167  
168                        IF( MYROW.EQ.IAROW )
169       $                    II = II + JB
170                            IAROW = MOD( IAROW + 1 , NPROW )
171                            IACOL = MOD( IACOL + 1 , NPCOL )
172  
173  *                         Loop over remaining block of columns
174  
175                            DO 160 J = JN + 1 , JA + N - 1 , DESCA( NB_ )
176                                JB = MIN( JA + N - J , DESCA( NB_ ) )
177  
178                                IF( MYCOL.EQ.IACOL ) THEN
179                                    IF( MYROW.EQ.IAROW ) THEN
180                                        DO 130 LL = JJ , JJ + JB - 1
181                                            CJ = SC( LL )
182                                            DO 120 KK = II + LL - JJ , IIA + NP - 1
183                                                A( IOFFA + KK ) = CJ*SR( KK )*A( IOFFA + KK )
184    120                                     CONTINUE
185                                            IOFFA = IOFFA + LDA
186    130                                 CONTINUE
187                                    ELSE
188                                        DO 150 LL = JJ , JJ + JB - 1
189                                            CJ = SC( LL )
190                                            DO 140 KK = II , IIA + NP - 1
191                                                A( IOFFA + KK ) = CJ*SR( KK )*A( IOFFA + KK )
192    140                                     CONTINUE
193                                            IOFFA = IOFFA + LDA
194    150                                 CONTINUE
195                                    END IF
196                                    JJ = JJ + JB
197                                END IF
198  
199                                IF( MYROW.EQ.IAROW )
200       $                            II = II + JB
201                                    IAROW = MOD( IAROW + 1 , NPROW )
202                                    IACOL = MOD( IACOL + 1 , NPCOL )
203  
204    160                     CONTINUE
205  
206                        END IF
207  
208                        EQUED = 'Y'
209  
210                    END IF
211  
212                    RETURN
213  
214  *                 End of PDLAQSY
215  
216                END