Routine: PSPOTRF()  File: SRC\pspotrf.f

 
 
# lines: 361
  # code: 361
  # comment: 0
  # blank:0
# Variables:35
# Callers:3
# Callings:1
# Words:184
# Keywords:118
 

 

..
     .. Array Arguments ..
     ..
  Purpose
  =======
  PSPOTRF computes the Cholesky factorization of an N-by-N real
  symmetric positive definite distributed matrix sub( A ) denoting
  A(IA:IA+N-1, JA:JA+N-1).
  The factorization has the form
            sub( A ) = U' * U ,  if UPLO = 'U', or
            sub( A ) = L  * L',  if UPLO = 'L',
  where U is an upper triangular matrix and L is lower triangular.
  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
  This routine requires square block decomposition ( MB_A = NB_A ).
  Arguments
  =========
  UPLO    (global input) CHARACTER
          = 'U':  Upper triangle of sub( A ) is stored;
          = 'L':  Lower triangle of sub( A ) is stored.
  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       (local input/local output) REAL pointer into the
          local memory to an array of dimension (LLD_A, LOCc(JA+N-1)).
          On entry, this array contains the local pieces of the
          N-by-N symmetric distributed matrix sub( A ) to be factored.
          If UPLO = 'U', the leading N-by-N upper triangular part of
          sub( A ) contains the upper triangular part of the matrix,
          and its strictly lower triangular part is not referenced.
          If UPLO = 'L', the leading N-by-N lower triangular part of
          sub( A ) contains the lower triangular part of the distribu-
          ted matrix, and its strictly upper triangular part is not
          referenced. On exit, if UPLO = 'U', the upper triangular
          part of the distributed matrix contains the Cholesky factor
          U, if UPLO = 'L', the lower triangular part of the distribu-
          ted matrix contains the Cholesky factor L.
  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.
  INFO    (global output) INTEGER
          = 0:  successful exit
          < 0:  If the i-th argument is an array and the j-entry had
                an illegal value, then INFO = -(i*100+j), if the i-th
                argument is a scalar and had an illegal value, then
                INFO = -i.
          > 0:  If INFO = K, the leading minor of order K,
                A(IA:IA+K-1,JA:JA+K-1) is not positive definite, and
                the factorization could not be completed.
  =====================================================================
     .. Parameters ..

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

 
001        SUBROUTINE PSPOTRF( UPLO , N , A , IA , JA , DESCA , INFO )
002  
003  *     -- ScaLAPACK routine(version 1.7) --
004  *     University of Tennessee , Knoxville , Oak Ridge National Laboratory ,
005  *     and University of California , Berkeley.
006  *     May 25 , 2001
007  
008  *     .. Scalar Arguments ..
009        CHARACTER UPLO
010        INTEGER IA , INFO , JA , N
011        INTEGER BLOCK_CYCLIC_2D , CSRC_ , CTXT_ , DLEN_ , DTYPE_ ,
012       $LLD_ , MB_ , M_ , NB_ , N_ , RSRC_
013        PARAMETER( BLOCK_CYCLIC_2D = 1 , DLEN_ = 9 , DTYPE_ = 1 ,
014       $CTXT_ = 2 , M_ = 3 , N_ = 4 , MB_ = 5 , NB_ = 6 ,
015       $RSRC_ = 7 , CSRC_ = 8 , LLD_ = 9 )
016        REAL ONE
017        PARAMETER( ONE = 1.0E + 0 )
018  *     ..
019  *     .. Local Scalars ..
020        LOGICAL UPPER
021        CHARACTER COLBTOP , ROWBTOP
022        INTEGER I , ICOFF , ICTXT , IROFF , J , JB , JN , MYCOL ,
023       $MYROW , NPCOL , NPROW
024  *     ..
025  *     .. Local Arrays ..
026        INTEGER IDUM1( 1 ) , IDUM2( 1 )
027  *     ..
028  *     .. External Subroutines ..
029        EXTERNAL BLACS_GRIDINFO , CHK1MAT , PCHK1MAT , PB_TOPGET ,
030       $PB_TOPSET , PSPOTF2 , PSSYRK , PSTRSM ,
031       $PXERBLA
032  *     ..
033  *     .. External Functions ..
034        LOGICAL LSAME
035        INTEGER ICEIL
036        EXTERNAL ICEIL , LSAME
037  *     ..
038  *     .. Intrinsic Functions ..
039        INTRINSIC ICHAR , MIN , MOD
040  *     ..
041  *     .. Executable Statements ..
042  
043  *     Get grid parameters
044  
045        ICTXT = DESCA( CTXT_ )
046        CALL BLACS_GRIDINFO( ICTXT , NPROW , NPCOL , MYROW , MYCOL )
047  
048  *     Test the input parameters
049  
050        INFO = 0
051        IF( NPROW.EQ. - 1 ) THEN
052            INFO = - (600 + CTXT_)
053        ELSE
054            CALL CHK1MAT( N , 2 , N , 2 , IA , JA , DESCA , 6 , INFO )
055            UPPER = LSAME( UPLO , 'U' )
056            IF( INFO.EQ.0 ) THEN
057                IROFF = MOD( IA - 1 , DESCA( MB_ ) )
058                ICOFF = MOD( JA - 1 , DESCA( NB_ ) )
059                IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO , 'L' ) ) THEN
060                    INFO = - 1
061                ELSE IF( IROFF.NE.0 ) THEN
062                    INFO = - 4
063                ELSE IF( ICOFF.NE.0 ) THEN
064                    INFO = - 5
065                ELSE IF( DESCA( MB_ ).NE.DESCA( NB_ ) ) THEN
066                    INFO = - (600 + NB_)
067                END IF
068            END IF
069            IF( UPPER ) THEN
070                IDUM1( 1 ) = ICHAR( 'U' )
071            ELSE
072                IDUM1( 1 ) = ICHAR( 'L' )
073            END IF
074            IDUM2( 1 ) = 1
075            CALL PCHK1MAT( N , 2 , N , 2 , IA , JA , DESCA , 6 , 1 , IDUM1 , IDUM2 ,
076       $    INFO )
077        END IF
078  
079        IF( INFO.NE.0 ) THEN
080            CALL PXERBLA( ICTXT , 'PSPOTRF' , - INFO )
081            RETURN
082        END IF
083  
084  *     Quick return if possible
085  
086        IF( N.EQ.0 )
087       $    RETURN
088  
089            CALL PB_TOPGET( ICTXT , 'Broadcast' , 'Rowwise' , ROWBTOP )
090            CALL PB_TOPGET( ICTXT , 'Broadcast' , 'Columnwise' , COLBTOP )
091  
092            IF( UPPER ) THEN
093  
094  *             Split - ring topology for the communication along process
095  *             columns , 1 - tree topology along process rows.
096  
097                CALL PB_TOPSET( ICTXT , 'Broadcast' , 'Rowwise' , ' ' )
098                CALL PB_TOPSET( ICTXT , 'Broadcast' , 'Columnwise' , 'S - ring' )
099  
100  *             A is upper triangular , compute Cholesky factorization A = U'*U.
101  
102  *             Handle the first block of columns separately
103  
104                JN = MIN( ICEIL( JA , DESCA( NB_ ) )*DESCA(NB_) , JA + N - 1 )
105                JB = JN - JA + 1
106  
107  *             Perform unblocked Cholesky factorization on JB block
108  
109                CALL PSPOTF2 ( UPLO , JB , A , IA , JA , DESCA , INFO )
110                IF( INFO.NE.0 )
111       $            GO TO 30
112  
113                    IF( JB + 1.LE.N ) THEN
114  
115  *                     Form the row panel of U using the triangular solver
116  
117                        CALL PSTRSM( 'Left' , UPLO , 'Transpose' , 'Non - Unit' ,
118       $                JB , N - JB , ONE , A , IA , JA , DESCA , A , IA , JA + JB ,
119       $                DESCA )
120  
121  *                     Update the trailing matrix , A = A - U'*U
122  
123                        CALL PSSYRK( UPLO , 'Transpose' , N - JB , JB , - ONE , A , IA ,
124       $                JA + JB , DESCA , ONE , A , IA + JB , JA + JB , DESCA )
125                    END IF
126  
127  *                 Loop over remaining block of columns
128  
129                    DO 10 J = JN + 1 , JA + N - 1 , DESCA( NB_ )
130                        JB = MIN( N - J + JA , DESCA( NB_ ) )
131                        I = IA + J - JA
132  
133  *                     Perform unblocked Cholesky factorization on JB block
134  
135                        CALL PSPOTF2 ( UPLO , JB , A , I , J , DESCA , INFO )
136                        IF( INFO.NE.0 ) THEN
137                            INFO = INFO + J - JA
138                            GO TO 30
139                        END IF
140  
141                        IF( J - JA + JB + 1.LE.N ) THEN
142  
143  *                         Form the row panel of U using the triangular solver
144  
145                            CALL PSTRSM( 'Left' , UPLO , 'Transpose' , 'Non - Unit' ,
146       $                    JB , N - J - JB + JA , ONE , A , I , J , DESCA , A ,
147       $                    I , J + JB , DESCA )
148  
149  *                         Update the trailing matrix , A = A - U'*U
150  
151                            CALL PSSYRK( UPLO , 'Transpose' , N - J - JB + JA , JB ,
152       $                    - ONE , A , I , J + JB , DESCA , ONE , A , I + JB ,
153       $                    J + JB , DESCA )
154                        END IF
155     10             CONTINUE
156  
157                ELSE
158  
159  *                 1 - tree topology for the communication along process columns ,
160  *                 Split - ring topology along process rows.
161  
162                    CALL PB_TOPSET( ICTXT , 'Broadcast' , 'Rowwise' , 'S - ring' )
163                    CALL PB_TOPSET( ICTXT , 'Broadcast' , 'Columnwise' , ' ' )
164  
165  *                 A is lower triangular , compute Cholesky factorization A = L*L'
166  *                 (right - looking)
167  
168  *                 Handle the first block of columns separately
169  
170                    JN = MIN( ICEIL( JA , DESCA( NB_ ) )*DESCA( NB_ ) , JA + N - 1 )
171                    JB = JN - JA + 1
172  
173  *                 Perform unblocked Cholesky factorization on JB block
174  
175                    CALL PSPOTF2 ( UPLO , JB , A , IA , JA , DESCA , INFO )
176                    IF( INFO.NE.0 )
177       $                GO TO 30
178  
179                        IF( JB + 1.LE.N ) THEN
180  
181  *                         Form the column panel of L using the triangular solver
182  
183                            CALL PSTRSM( 'Right' , UPLO , 'Transpose' , 'Non - Unit' ,
184       $                    N - JB , JB , ONE , A , IA , JA , DESCA , A , IA + JB , JA ,
185       $                    DESCA )
186  
187  *                         Update the trailing matrix , A = A - L*L'
188  
189                            CALL PSSYRK( UPLO , 'No Transpose' , N - JB , JB , - ONE , A , IA + JB ,
190       $                    JA , DESCA , ONE , A , IA + JB , JA + JB , DESCA )
191  
192                        END IF
193  
194                        DO 20 J = JN + 1 , JA + N - 1 , DESCA( NB_ )
195                            JB = MIN( N - J + JA , DESCA( NB_ ) )
196                            I = IA + J - JA
197  
198  *                         Perform unblocked Cholesky factorization on JB block
199  
200                            CALL PSPOTF2 ( UPLO , JB , A , I , J , DESCA , INFO )
201                            IF( INFO.NE.0 ) THEN
202                                INFO = INFO + J - JA
203                                GO TO 30
204                            END IF
205  
206                            IF( J - JA + JB + 1.LE.N ) THEN
207  
208  *                             Form the column panel of L using the triangular solver
209  
210                                CALL PSTRSM( 'Right' , UPLO , 'Transpose' , 'Non - Unit' ,
211       $                        N - J - JB + JA , JB , ONE , A , I , J , DESCA , A , I + JB ,
212       $                        J , DESCA )
213  
214  *                             Update the trailing matrix , A = A - L*L'
215  
216                                CALL PSSYRK( UPLO , 'No Transpose' , N - J - JB + JA , JB , - ONE ,
217       $                        A , I + JB , J , DESCA , ONE , A , I + JB , J + JB ,
218       $                        DESCA )
219  
220                            END IF
221     20                 CONTINUE
222  
223                    END IF
224  
225     30 CONTINUE
226  
227        CALL PB_TOPSET( ICTXT , 'Broadcast' , 'Rowwise' , ROWBTOP )
228        CALL PB_TOPSET( ICTXT , 'Broadcast' , 'Columnwise' , COLBTOP )
229  
230        RETURN
231  
232  *     End of PSPOTRF
233  
234        END