Routine: PZLACON()  File: SRC\pzlacon.f

 
 
# lines: 384
  # code: 384
  # comment: 0
  # blank:0
# Variables:56
# Callers:6
# Callings:3
# Words:266
# Keywords:169
 

 

..
     .. Array Arguments ..
     ..
  Purpose
  =======
  PZLACON estimates the 1-norm of a square, complex 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) COMPLEX*16 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) COMPLEX*16 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,
          where A' is the conjugate transpose of A, and PZLACON 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.
  EST     (global output) DOUBLE PRECISION
          An estimate (a lower bound) for norm(A).
  KASE    (local input/local output) INTEGER
          On the initial call to PZLACON, 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 PZLACON, KASE will again be 0.
  Further Details
  ===============
  The serial version ZLACON 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 PZLACON( N , V , IV , JV , DESCV , X , IX , JX , DESCX , EST ,
002       $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 ONE , TWO
020        PARAMETER( ONE = 1.0D + 0 , TWO = 2.0D + 0 )
021        COMPLEX*16 CZERO , CONE
022        PARAMETER( CZERO =( 0.0D + 0 , 0.0D + 0 ) ,
023       $CONE =( 1.0D + 0 , 0.0D + 0 ) )
024  *     ..
025  *     .. Local Scalars ..
026        INTEGER I , ICTXT , IIVX , IMAXROW , IOFFVX , IROFF , ITER ,
027       $IVXCOL , IVXROW , J , JLAST , JJVX , JUMP , K ,
028       $MYCOL , MYROW , NP , NPCOL , NPROW
029        DOUBLE PRECISION ALTSGN , ESTOLD , SAFMIN , TEMP
030        COMPLEX*16 JLMAX , XMAX
031  *     ..
032  *     .. Local Arrays ..
033        COMPLEX*16 WORK( 2 )
034  *     ..
035  *     .. External Subroutines ..
036        EXTERNAL BLACS_GRIDINFO , INFOG2L , DGEBR2D ,
037       $DGEBS2D , PDZSUM1 , PZELGET ,
038       $PZMAX1 , ZCOPY , ZGEBR2D , ZGEBS2D
039  *     ..
040  *     .. External Functions ..
041        INTEGER INDXG2L , INDXG2P , INDXL2G , NUMROC
042        DOUBLE PRECISION PDLAMCH
043        EXTERNAL INDXG2L , INDXG2P , INDXL2G , NUMROC , PDLAMCH
044  *     ..
045  *     .. Intrinsic Functions ..
046        INTRINSIC ABS , DBLE , DCMPLX
047  *     ..
048  *     .. Save statement ..
049        SAVE
050  *     ..
051  *     .. Executable Statements ..
052  
053  *     Get grid parameters.
054  
055        ICTXT = DESCX( CTXT_ )
056        CALL BLACS_GRIDINFO( ICTXT , NPROW , NPCOL , MYROW , MYCOL )
057  
058        CALL INFOG2L( IX , JX , DESCX , NPROW , NPCOL , MYROW , MYCOL ,
059       $IIVX , JJVX , IVXROW , IVXCOL )
060        IF( MYCOL.NE.IVXCOL )
061       $    RETURN
062            IROFF = MOD( IX - 1 , DESCX( MB_ ) )
063            NP = NUMROC( N + IROFF , DESCX( MB_ ) , MYROW , IVXROW , NPROW )
064            IF( MYROW.EQ.IVXROW )
065       $        NP = NP - IROFF
066                IOFFVX = IIVX + (JJVX - 1)*DESCX( LLD_ )
067  
068                SAFMIN = PDLAMCH( ICTXT , 'Safe minimum' )
069                IF( KASE.EQ.0 ) THEN
070                    DO 10 I = IOFFVX , IOFFVX + NP - 1
071                        X( I ) = DCMPLX( ONE / DBLE( N ) )
072     10             CONTINUE
073                    KASE = 1
074                    JUMP = 1
075                    RETURN
076                END IF
077  
078                GO TO( 20 , 40 , 70 , 90 , 120 )JUMP
079  
080  *             ................ ENTRY(JUMP = 1)
081  *             FIRST ITERATION. X HAS BEEN OVERWRITTEN BY A*X
082  
083     20 CONTINUE
084        IF( N.EQ.1 ) THEN
085            IF( MYROW.EQ.IVXROW ) THEN
086                V( IOFFVX ) = X( IOFFVX )
087                EST = ABS( V( IOFFVX ) )
088                CALL DGEBS2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , EST , 1 )
089            ELSE
090                CALL DGEBR2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , EST , 1 ,
091       $        IVXROW , MYCOL )
092            END IF
093  *         ... QUIT
094            GO TO 130
095        END IF
096        CALL PDZSUM1 ( N , EST , X , IX , JX , DESCX , 1 )
097        IF( DESCX( M_ ).EQ.1 .AND. N.EQ.1 ) THEN
098            IF( MYROW.EQ.IVXROW ) THEN
099                CALL DGEBS2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , EST , 1 )
100            ELSE
101                CALL DGEBR2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , EST , 1 ,
102       $        IVXROW , MYCOL )
103            END IF
104        END IF
105  
106        DO 30 I = IOFFVX , IOFFVX + NP - 1
107            IF( ABS( X( I ) ).GT.SAFMIN ) THEN
108                X( I ) = X( I ) / DCMPLX( ABS( X( I ) ) )
109            ELSE
110                X( I ) = CONE
111            END IF
112     30 CONTINUE
113        KASE = 2
114        JUMP = 2
115        RETURN
116  
117  *     ................ ENTRY(JUMP = 2)
118  *     FIRST ITERATION. X HAS BEEN OVERWRITTEN BY CTRANS(A)*X
119  
120     40 CONTINUE
121        CALL PZMAX1 ( N , XMAX , J , X , IX , JX , DESCX , 1 )
122        IF( DESCX( M_ ).EQ.1 .AND. N.EQ.1 ) THEN
123            IF( MYROW.EQ.IVXROW ) THEN
124                WORK( 1 ) = XMAX
125                WORK( 2 ) = DCMPLX( DBLE( J ) )
126                CALL ZGEBS2D( ICTXT , 'Columnwise' , ' ' , 2 , 1 , WORK , 2 )
127            ELSE
128                CALL ZGEBR2D( ICTXT , 'Columnwise' , ' ' , 2 , 1 , WORK , 2 ,
129       $        IVXROW , MYCOL )
130                XMAX = WORK( 1 )
131                J = NINT( DBLE( WORK( 2 ) ) )
132            END IF
133        END IF
134        ITER = 2
135  
136  *     MAIN LOOP - ITERATIONS 2 , 3 , ... , ITMAX
137  
138     50 CONTINUE
139        DO 60 I = IOFFVX , IOFFVX + NP - 1
140            X( I ) = CZERO
141     60 CONTINUE
142        IMAXROW = INDXG2P( J , DESCX( MB_ ) , MYROW , DESCX( RSRC_ ) , NPROW )
143        IF( MYROW.EQ.IMAXROW ) THEN
144            I = INDXG2L( J , DESCX( MB_ ) , MYROW , DESCX( RSRC_ ) , NPROW )
145            X( I ) = CONE
146        END IF
147        KASE = 1
148        JUMP = 3
149        RETURN
150  
151  *     ................ ENTRY(JUMP = 3)
152  *     X HAS BEEN OVERWRITTEN BY A*X
153  
154     70 CONTINUE
155        CALL ZCOPY( NP , X( IOFFVX ) , 1 , V( IOFFVX ) , 1 )
156        ESTOLD = EST
157        CALL PDZSUM1 ( N , EST , V , IV , JV , DESCV , 1 )
158        IF( DESCV( M_ ).EQ.1 .AND. N.EQ.1 ) THEN
159            IF( MYROW.EQ.IVXROW ) THEN
160                CALL DGEBS2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , EST , 1 )
161            ELSE
162                CALL DGEBR2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , EST , 1 ,
163       $        IVXROW , MYCOL )
164            END IF
165        END IF
166  
167  *     TEST FOR CYCLING
168        IF( EST.LE.ESTOLD )
169       $    GO TO 100
170  
171            DO 80 I = IOFFVX , IOFFVX + NP - 1
172                IF( ABS( X( I ) ).GT.SAFMIN ) THEN
173                    X( I ) = X( I ) / DCMPLX( ABS( X( I ) ) )
174                ELSE
175                    X( I ) = CONE
176                END IF
177     80     CONTINUE
178            KASE = 2
179            JUMP = 4
180            RETURN
181  
182  *         ................ ENTRY(JUMP = 4)
183  *         X HAS BEEN OVERWRITTEN BY CTRANS(A)*X
184  
185     90 CONTINUE
186        JLAST = J
187        CALL PZMAX1 ( 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 ) = DCMPLX( DBLE( J ) )
192                CALL ZGEBS2D( ICTXT , 'Columnwise' , ' ' , 2 , 1 , WORK , 2 )
193            ELSE
194                CALL ZGEBR2D( ICTXT , 'Columnwise' , ' ' , 2 , 1 , WORK , 2 ,
195       $        IVXROW , MYCOL )
196                XMAX = WORK( 1 )
197                J = NINT( DBLE( WORK( 2 ) ) )
198            END IF
199        END IF
200        CALL PZELGET( 'Columnwise' , ' ' , JLMAX , X , JLAST , JX , DESCX )
201        IF(( DBLE( JLMAX ).NE.ABS( DBLE( XMAX ) ) ).AND.
202       $( ITER.LT.ITMAX ) ) THEN
203        ITER = ITER + 1
204        GO TO 50
205        END IF
206  
207  *     ITERATION COMPLETE. FINAL STAGE.
208  
209    100 CONTINUE
210        DO 110 I = IOFFVX , IOFFVX + NP - 1
211            K = INDXL2G( I - IOFFVX + IIVX , DESCX( MB_ ) , MYROW ,
212       $    DESCX( RSRC_ ) , NPROW ) - IX + 1
213            IF( MOD( K , 2 ).EQ.0 ) THEN
214                ALTSGN = - ONE
215            ELSE
216                ALTSGN = ONE
217            END IF
218            X( I ) = DCMPLX( ALTSGN*( ONE + DBLE( K - 1 ) / DBLE( N - 1 ) ) )
219    110 CONTINUE
220        KASE = 1
221        JUMP = 5
222        RETURN
223  
224  *     ................ ENTRY(JUMP = 5)
225  *     X HAS BEEN OVERWRITTEN BY A*X
226  
227    120 CONTINUE
228        CALL PDZSUM1 ( N , TEMP , X , IX , JX , DESCX , 1 )
229        IF( DESCX( M_ ).EQ.1 .AND. N.EQ.1 ) THEN
230            IF( MYROW.EQ.IVXROW ) THEN
231                CALL DGEBS2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , TEMP , 1 )
232            ELSE
233                CALL DGEBR2D( ICTXT , 'Columnwise' , ' ' , 1 , 1 , TEMP , 1 ,
234       $        IVXROW , MYCOL )
235            END IF
236        END IF
237        TEMP = TWO*( TEMP / DBLE( 3*N ) )
238        IF( TEMP.GT.EST ) THEN
239            CALL ZCOPY( NP , X( IOFFVX ) , 1 , V( IOFFVX ) , 1 )
240            EST = TEMP
241        END IF
242  
243    130 CONTINUE
244        KASE = 0
245  
246        RETURN
247  
248  *     End of PZLACON
249  
250        END