Routine: PDLACON()  File: SRC\pdlacon.f

 
 
# lines: 386
  # code: 386
  # comment: 0
  # blank:0
# Variables:55
# Callers:6
# Callings:0
# Words:257
# Keywords:170
 

 

..
     .. Array Arguments ..
     ..
  Purpose
  =======
  PDLACON estimates the 1-norm of a square, real distributed matrix A.
  Reverse communication is used for evaluating matrix-vector products.
  X and V are aligned with the distributed matrix A, this information
  is implicitly contained within IV, IX, DESCV, and DESCX.
  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
  =========
  N       (global input) INTEGER
          The length of the distributed vectors V and X.  N >= 0.
  V       (local workspace) DOUBLE PRECISION pointer into the local
          memory to an array of dimension LOCr(N+MOD(IV-1,MB_V)). On
          the final return, V = A*W, where EST = norm(V)/norm(W)
          (W is not returned).
  IV      (global input) INTEGER
          The row index in the global array V indicating the first
          row of sub( V ).
  JV      (global input) INTEGER
          The column index in the global array V indicating the
          first column of sub( V ).
  DESCV   (global and local input) INTEGER array of dimension DLEN_.
          The array descriptor for the distributed matrix V.
  X       (local input/local output) DOUBLE PRECISION pointer into the
          local memory to an array of dimension
          LOCr(N+MOD(IX-1,MB_X)). On an intermediate return, X
          should be overwritten by
                A * X,   if KASE=1,
                A' * X,  if KASE=2,
          PDLACON must be re-called with all the other parameters
          unchanged.
  IX      (global input) INTEGER
          The row index in the global array X indicating the first
          row of sub( X ).
  JX      (global input) INTEGER
          The column index in the global array X indicating the
          first column of sub( X ).
  DESCX   (global and local input) INTEGER array of dimension DLEN_.
          The array descriptor for the distributed matrix X.
  ISGN    (local workspace) INTEGER array, dimension
          LOCr(N+MOD(IX-1,MB_X)). ISGN is aligned with X and V.
  EST     (global output) DOUBLE PRECISION
          An estimate (a lower bound) for norm(A).
  KASE    (local input/local output) INTEGER
          On the initial call to PDLACON, KASE should be 0.
          On an intermediate return, KASE will be 1 or 2, indicating
          whether X should be overwritten by A * X  or A' * X.
          On the final return from PDLACON, KASE will again be 0.
  Further Details
  ===============
  The serial version DLACON has been contributed by Nick Higham,
  University of Manchester. It was originally named SONEST, dated
  March 16, 1988.
  Reference: N.J. Higham, "FORTRAN codes for estimating the one-norm of
  a real or complex matrix, with applications to condition estimation",
  ACM Trans. Math. Soft., vol. 14, no. 4, pp. 381-396, December 1988.
  =====================================================================
     .. Parameters ..

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

 
001        SUBROUTINE PDLACON( N , V , IV , JV , DESCV , X , IX , JX , DESCX , ISGN ,
002       $EST , KASE )
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        INTEGER IV , IX , JV , JX , KASE , N
011        DOUBLE PRECISION EST
012        INTEGER BLOCK_CYCLIC_2D , CSRC_ , CTXT_ , DLEN_ , DTYPE_ ,
013       $LLD_ , MB_ , M_ , NB_ , N_ , RSRC_
014        PARAMETER( BLOCK_CYCLIC_2D = 1 , DLEN_ = 9 , DTYPE_ = 1 ,
015       $CTXT_ = 2 , M_ = 3 , N_ = 4 , MB_ = 5 , NB_ = 6 ,
016       $RSRC_ = 7 , CSRC_ = 8 , LLD_ = 9 )
017        INTEGER ITMAX
018        PARAMETER( ITMAX = 5 )
019        DOUBLE PRECISION ZERO , ONE , TWO
020        PARAMETER( ZERO = 0.0D + 0 , ONE = 1.0D + 0 , TWO = 2.0D + 0 )
021  *     ..
022  *     .. Local Scalars ..
023        INTEGER I , ICTXT , IFLAG , IIVX , IMAXROW , IOFFVX , IROFF ,
024       $ITER , IVXCOL , IVXROW , J , JLAST , JJVX , JUMP ,
025       $K , MYCOL , MYROW , NP , NPCOL , NPROW
026        DOUBLE PRECISION ALTSGN , ESTOLD , JLMAX , TEMP , XMAX
027  *     ..
028  *     .. Local Arrays ..
029        DOUBLE PRECISION WORK( 2 )
030  *     ..
031  *     .. External Subroutines ..
032        EXTERNAL BLACS_GRIDINFO , DCOPY , DGEBR2D , DGEBS2D ,
033       $IGSUM2D , INFOG2L , PDAMAX , PDASUM ,
034       $PDELGET
035  *     ..
036  *     .. External Functions ..
037        INTEGER INDXG2L , INDXG2P , INDXL2G , NUMROC
038        EXTERNAL INDXG2L , INDXG2P , INDXL2G , NUMROC
039  *     ..
040  *     .. Intrinsic Functions ..
041        INTRINSIC ABS , DBLE , MOD , NINT , SIGN
042  *     ..
043  *     .. Save statement ..
044        SAVE
045  *     ..
046  *     .. Executable Statements ..
047  
048  *     Get grid parameters.
049  
050        ICTXT = DESCX( CTXT_ )
051        CALL BLACS_GRIDINFO( ICTXT , NPROW , NPCOL , MYROW , MYCOL )
052  
053        CALL INFOG2L( IX , JX , DESCX , NPROW , NPCOL , MYROW , MYCOL ,
054       $IIVX , JJVX , IVXROW , IVXCOL )
055        IF( MYCOL.NE.IVXCOL )
056       $    RETURN
057            IROFF = MOD( IX - 1 , DESCX( MB_ ) )
058            NP = NUMROC( N + IROFF , DESCX( MB_ ) , MYROW , IVXROW , NPROW )
059            IF( MYROW.EQ.IVXROW )
060       $        NP = NP - IROFF
061                IOFFVX = IIVX + (JJVX - 1)*DESCX( LLD_ )
062  
063                IF( KASE.EQ.0 ) THEN
064                    DO 10 I = IOFFVX , IOFFVX + NP - 1
065                        X( I ) = ONE / DBLE( N )
066     10             CONTINUE
067                    KASE = 1
068                    JUMP = 1
069                    RETURN
070                END IF
071  
072                GO TO( 20 , 40 , 70 , 110 , 140 )JUMP
073  
074  *             ................ ENTRY(JUMP = 1)
075  *             FIRST ITERATION. X HAS BEEN OVERWRITTEN BY A*X
076  
077     20 CONTINUE
078        IF( N.EQ.1 ) THEN
079            IF( MYROW.EQ.IVXROW ) THEN
080                V( IOFFVX ) = X( IOFFVX )
081                EST = ABS( V( IOFFVX ) )
082                CALL DGEBS2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , EST , 1 )
083            ELSE
084                CALL DGEBR2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , EST , 1 ,
085       $        IVXROW , MYCOL )
086            END IF
087  *         ... QUIT
088            GO TO 150
089        END IF
090        CALL PDASUM( N , EST , X , IX , JX , DESCX , 1 )
091        IF( DESCX( M_ ).EQ.1 .AND. N.EQ.1 ) THEN
092            IF( MYROW.EQ.IVXROW ) THEN
093                CALL DGEBS2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , EST , 1 )
094            ELSE
095                CALL DGEBR2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , EST , 1 ,
096       $        IVXROW , MYCOL )
097            END IF
098        END IF
099  
100        DO 30 I = IOFFVX , IOFFVX + NP - 1
101            X( I ) = SIGN( ONE , X( I ) )
102            ISGN( I ) = NINT( X( I ) )
103     30 CONTINUE
104        KASE = 2
105        JUMP = 2
106        RETURN
107  
108  *     ................ ENTRY(JUMP = 2)
109  *     FIRST ITERATION. X HAS BEEN OVERWRITTEN BY TRANSPOSE(A)*X
110  
111     40 CONTINUE
112        CALL PDAMAX( N , XMAX , J , X , IX , JX , DESCX , 1 )
113        IF( DESCX( M_ ).EQ.1 .AND. N.EQ.1 ) THEN
114            IF( MYROW.EQ.IVXROW ) THEN
115                WORK( 1 ) = XMAX
116                WORK( 2 ) = DBLE( J )
117                CALL DGEBS2D( ICTXT , 'Columnwise' , ' ' , 2 , 1 , WORK , 2 )
118            ELSE
119                CALL DGEBR2D( ICTXT , 'Columnwise' , ' ' , 2 , 1 , WORK , 2 ,
120       $        IVXROW , MYCOL )
121                XMAX = WORK( 1 )
122                J = NINT( WORK( 2 ) )
123            END IF
124        END IF
125        ITER = 2
126  
127  *     MAIN LOOP - ITERATIONS 2 , 3 , ... , ITMAX
128  
129     50 CONTINUE
130        DO 60 I = IOFFVX , IOFFVX + NP - 1
131            X( I ) = ZERO
132     60 CONTINUE
133        IMAXROW = INDXG2P( J , DESCX( MB_ ) , MYROW , DESCX( RSRC_ ) , NPROW )
134        IF( MYROW.EQ.IMAXROW ) THEN
135            I = INDXG2L( J , DESCX( MB_ ) , MYROW , DESCX( RSRC_ ) , NPROW )
136            X( I ) = ONE
137        END IF
138        KASE = 1
139        JUMP = 3
140        RETURN
141  
142  *     ................ ENTRY(JUMP = 3)
143  *     X HAS BEEN OVERWRITTEN BY A*X
144  
145     70 CONTINUE
146        CALL DCOPY( NP , X( IOFFVX ) , 1 , V( IOFFVX ) , 1 )
147        ESTOLD = EST
148        CALL PDASUM( N , EST , V , IV , JV , DESCV , 1 )
149        IF( DESCV( M_ ).EQ.1 .AND. N.EQ.1 ) THEN
150            IF( MYROW.EQ.IVXROW ) THEN
151                CALL DGEBS2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , EST , 1 )
152            ELSE
153                CALL DGEBR2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , EST , 1 ,
154       $        IVXROW , MYCOL )
155            END IF
156        END IF
157        IFLAG = 0
158        DO 80 I = IOFFVX , IOFFVX + NP - 1
159            IF( NINT( SIGN( ONE , X( I ) ) ).NE.ISGN( I ) ) THEN
160                IFLAG = 1
161                GO TO 90
162            END IF
163     80 CONTINUE
164  
165     90 CONTINUE
166        CALL IGSUM2D( ICTXT , 'C' , ' ' , 1 , 1 , IFLAG , 1 , - 1 , MYCOL )
167  
168  *     REPEATED SIGN VECTOR DETECTED , HENCE ALGORITHM HAS CONVERGED.
169  *     ALONG WITH IT , TEST FOR CYCLING.
170  
171        IF( IFLAG.EQ.0 .OR. EST.LE.ESTOLD )
172       $    GO TO 120
173  
174            DO 100 I = IOFFVX , IOFFVX + NP - 1
175                X( I ) = SIGN( ONE , X( I ) )
176                ISGN( I ) = NINT( X( I ) )
177    100     CONTINUE
178            KASE = 2
179            JUMP = 4
180            RETURN
181  
182  *         ................ ENTRY(JUMP = 4)
183  *         X HAS BEEN OVERWRITTEN BY TRANSPOSE(A)*X
184  
185    110 CONTINUE
186        JLAST = J
187        CALL PDAMAX( N , XMAX , J , X , IX , JX , DESCX , 1 )
188        IF( DESCX( M_ ).EQ.1 .AND. N.EQ.1 ) THEN
189            IF( MYROW.EQ.IVXROW ) THEN
190                WORK( 1 ) = XMAX
191                WORK( 2 ) = DBLE( J )
192                CALL DGEBS2D( ICTXT , 'Columnwise' , ' ' , 2 , 1 , WORK , 2 )
193            ELSE
194                CALL DGEBR2D( ICTXT , 'Columnwise' , ' ' , 2 , 1 , WORK , 2 ,
195       $        IVXROW , MYCOL )
196                XMAX = WORK( 1 )
197                J = NINT( WORK( 2 ) )
198            END IF
199        END IF
200        CALL PDELGET( 'Columnwise' , ' ' , JLMAX , X , JLAST , JX , DESCX )
201        IF(( JLMAX.NE.ABS( XMAX ) ).AND.( ITER.LT.ITMAX ) ) THEN
202            ITER = ITER + 1
203            GO TO 50
204        END IF
205  
206  *     ITERATION COMPLETE. FINAL STAGE.
207  
208    120 CONTINUE
209        DO 130 I = IOFFVX , IOFFVX + NP - 1
210            K = INDXL2G( I - IOFFVX + IIVX , DESCX( MB_ ) , MYROW ,
211       $    DESCX( RSRC_ ) , NPROW ) - IX + 1
212            IF( MOD( K , 2 ).EQ.0 ) THEN
213                ALTSGN = - ONE
214            ELSE
215                ALTSGN = ONE
216            END IF
217            X( I ) = ALTSGN*( ONE + DBLE( K - 1 ) / DBLE( N - 1 ) )
218    130 CONTINUE
219        KASE = 1
220        JUMP = 5
221        RETURN
222  
223  *     ................ ENTRY(JUMP = 5)
224  *     X HAS BEEN OVERWRITTEN BY A*X
225  
226    140 CONTINUE
227        CALL PDASUM( N , TEMP , X , IX , JX , DESCX , 1 )
228        IF( DESCX( M_ ).EQ.1 .AND. N.EQ.1 ) THEN
229            IF( MYROW.EQ.IVXROW ) THEN
230                CALL DGEBS2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , TEMP , 1 )
231            ELSE
232                CALL DGEBR2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , TEMP , 1 ,
233       $        IVXROW , MYCOL )
234            END IF
235        END IF
236        TEMP = TWO*( TEMP / DBLE( 3*N ) )
237        IF( TEMP.GT.EST ) THEN
238            CALL DCOPY( NP , X( IOFFVX ) , 1 , V( IOFFVX ) , 1 )
239            EST = TEMP
240        END IF
241  
242    150 CONTINUE
243        KASE = 0
244  
245        RETURN
246  
247  *     End of PDLACON
248  
249        END