Routine: PCTRTI2()  File: SRC\pctrti2.f

 
 
# lines: 276
  # code: 276
  # comment: 0
  # blank:0
# Variables:37
# Callers:1
# Callings:0
# Words:104
# Keywords:72
 

 

..
     .. Array Arguments ..
     ..
  Purpose
  =======
  PCTRTI2 computes the inverse of a complex upper or lower triangular
  block matrix sub( A ) = A(IA:IA+N-1,JA:JA+N-1). This matrix should be
  contained in one and only one process memory space (local operation).
  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*1
          = 'U':  sub( A ) is upper triangular;
          = 'L':  sub( A ) is lower triangular.
  DIAG    (global input) CHARACTER*1
          = 'N':  sub( A ) is non-unit triangular
          = 'U':  sub( A ) is unit 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       (local input/local output) COMPLEX pointer into the
          local memory to an array of dimension (LLD_A,LOCc(JA+N-1)),
          this array contains the local pieces of the triangular matrix
          sub( A ). If UPLO = 'U', the leading N-by-N upper triangular
          part of the matrix sub( A ) contains the upper triangular
          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 the matrix sub( A ) contains the lower
          triangular matrix, and the strictly upper triangular part
          of sub( A ) is not referenced. If DIAG = 'U', the diagonal
          elements of sub( A ) are also not referenced and are assumed
          to be 1.  On exit, the (triangular) inverse of the original
          matrix, in the same storage format.
  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    (local 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.
  =====================================================================
     .. Parameters ..

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

 
001        SUBROUTINE PCTRTI2( UPLO , DIAG , 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 1 , 1997
007  
008  *     .. Scalar Arguments ..
009        CHARACTER DIAG , 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        COMPLEX ONE
017        PARAMETER( ONE = 1.0E + 0 )
018  *     ..
019  *     .. Local Scalars ..
020        LOGICAL NOUNIT , UPPER
021        INTEGER IACOL , IAROW , ICTXT , ICURR , IDIAG , IIA , IOFFA ,
022       $JJA , LDA , MYCOL , MYROW , NA , NPCOL , NPROW
023        COMPLEX AJJ
024  *     ..
025  *     .. External Subroutines ..
026        EXTERNAL BLACS_ABORT , BLACS_GRIDINFO , CHK1MAT , CSCAL ,
027       $CTRMV , INFOG2L , PXERBLA
028  *     ..
029  *     .. External Functions ..
030        LOGICAL LSAME
031        EXTERNAL LSAME
032  *     ..
033  *     .. Executable Statements ..
034  
035  *     Get grid parameters
036  
037        ICTXT = DESCA( CTXT_ )
038        CALL BLACS_GRIDINFO( ICTXT , NPROW , NPCOL , MYROW , MYCOL )
039  
040  *     Test the input parameters
041  
042        INFO = 0
043        IF( NPROW.EQ. - 1 ) THEN
044            INFO = - (700 + CTXT_)
045        ELSE
046            CALL CHK1MAT( N , 3 , N , 3 , IA , JA , DESCA , 7 , INFO )
047            UPPER = LSAME( UPLO , 'U' )
048            NOUNIT = LSAME( DIAG , 'N' )
049            IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO , 'L' ) ) THEN
050                INFO = - 1
051            ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG , 'U' ) ) THEN
052                INFO = - 2
053            END IF
054        END IF
055  
056        IF( INFO.NE.0 ) THEN
057            CALL PXERBLA( ICTXT , 'PCTRTI2' , - INFO )
058            CALL BLACS_ABORT( ICTXT , 1 )
059            RETURN
060        END IF
061  
062  *     Compute local indexes
063  
064        CALL INFOG2L( IA , JA , DESCA , NPROW , NPCOL , MYROW , MYCOL , IIA , JJA ,
065       $IAROW , IACOL )
066  
067        IF( MYROW.EQ.IAROW .AND. MYCOL.EQ.IACOL ) THEN
068  
069            LDA = DESCA( LLD_ )
070  
071            IF( UPPER ) THEN
072  
073                IOFFA = IIA + ( JJA - 1 ) * LDA
074                ICURR = IOFFA + LDA
075  
076                IF( NOUNIT ) THEN
077  
078  *                 Compute inverse of upper non - unit triangular matrix.
079  
080                    A( IOFFA ) = ONE / A( IOFFA )
081                    IDIAG = ICURR + 1
082                    DO 10 NA = 1 , N - 1
083                        A( IDIAG ) = ONE / A( IDIAG )
084                        AJJ = - A( IDIAG )
085  
086  *                     Compute elements 1 : j - 1 of j - th column.
087  
088                        CALL CTRMV( 'Upper' , 'No transpose' , DIAG , NA ,
089       $                A( IOFFA ) , LDA , A( ICURR ) , 1 )
090                        CALL CSCAL( NA , AJJ , A( ICURR ) , 1 )
091                        IDIAG = IDIAG + LDA + 1
092                        ICURR = ICURR + LDA
093     10             CONTINUE
094  
095                ELSE
096  
097  *                 Compute inverse of upper unit triangular matrix.
098  
099                    DO 20 NA = 1 , N - 1
100  
101  *                     Compute elements 1 : j - 1 of j - th column.
102  
103                        CALL CTRMV( 'Upper' , 'No transpose' , DIAG , NA ,
104       $                A( IOFFA ) , LDA , A( ICURR ) , 1 )
105                        CALL CSCAL( NA , - ONE , A( ICURR ) , 1 )
106                        ICURR = ICURR + LDA
107     20             CONTINUE
108  
109                END IF
110  
111            ELSE
112  
113                ICURR = IIA + N - 1 + ( JJA + N - 2 ) * LDA
114                IOFFA = ICURR - LDA
115  
116                IF( NOUNIT ) THEN
117  
118  *                 Compute inverse of lower non - unit triangular matrix.
119  
120                    A( ICURR ) = ONE / A( ICURR )
121                    IDIAG = IOFFA - 1
122                    DO 30 NA = 1 , N - 1
123                        A( IDIAG ) = ONE / A( IDIAG )
124                        AJJ = - A( IDIAG )
125  
126  *                     Compute elements j + 1 : n of j - th column.
127  
128                        CALL CTRMV( 'Lower' , 'No transpose' , DIAG , NA ,
129       $                A( ICURR ) , LDA , A( IOFFA ) , 1 )
130                        CALL CSCAL( NA , AJJ , A( IOFFA ) , 1 )
131                        ICURR = IDIAG
132                        IDIAG = IDIAG - LDA - 1
133                        IOFFA = IDIAG + 1
134     30             CONTINUE
135  
136                ELSE
137  
138  *                 Compute inverse of lower unit triangular matrix.
139  
140                    DO 40 NA = 1 , N - 1
141  
142  *                     Compute elements j + 1 : n of j - th column.
143  
144                        CALL CTRMV( 'Lower' , 'No transpose' , DIAG , NA ,
145       $                A( ICURR ) , LDA , A( IOFFA ) , 1 )
146                        CALL CSCAL( NA , - ONE , A( IOFFA ) , 1 )
147                        ICURR = ICURR - LDA - 1
148                        IOFFA = ICURR - LDA
149     40             CONTINUE
150  
151                END IF
152  
153            END IF
154  
155        END IF
156  
157  *     End of PCTRTI2
158  
159        END