Routine: PDSYGS2()  File: SRC\pdsygs2.f

 
 
# lines: 419
  # code: 419
  # comment: 0
  # blank:0
# Variables:50
# Callers:1
# Callings:0
# Words:208
# Keywords:131
 

 

..
     .. Array Arguments ..
     ..
  Purpose
  =======
  PDSYGS2 reduces a real symmetric-definite generalized eigenproblem
  to standard form.
  In the following sub( A ) denotes A( IA:IA+N-1, JA:JA+N-1 ) and
  sub( B ) denotes B( IB:IB+N-1, JB:JB+N-1 ).
  If IBTYPE = 1, the problem is sub( A )*x = lambda*sub( B )*x,
  and sub( A ) is overwritten by inv(U**T)*sub( A )*inv(U) or
  inv(L)*sub( A )*inv(L**T)
  If IBTYPE = 2 or 3, the problem is sub( A )*sub( B )*x = lambda*x or
  sub( B )*sub( A )*x = lambda*x, and sub( A ) is overwritten by
  U*sub( A )*U**T or L**T*sub( A )*L.
  sub( B ) must have been previously factorized as U**T*U or L*L**T by
  PDPOTRF.
  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
  =========
  IBTYPE   (global input) INTEGER
          = 1: compute inv(U**T)*sub( A )*inv(U) or
               inv(L)*sub( A )*inv(L**T);
          = 2 or 3: compute U*sub( A )*U**T or L**T*sub( A )*L.
  UPLO    (global input) CHARACTER
          = 'U':  Upper triangle of sub( A ) is stored and sub( B ) is
                  factored as U**T*U;
          = 'L':  Lower triangle of sub( A ) is stored and sub( B ) is
                  factored as L*L**T.
  N       (global input) INTEGER
          The order of the matrices sub( A ) and sub( B ).  N >= 0.
  A       (local input/local output) DOUBLE PRECISION 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 ). 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 matrix, and its strictly
          upper triangular part is not referenced.
          On exit, if INFO = 0, the transformed matrix, stored in the
          same format as sub( A ).
  IA      (global input) INTEGER
          A's global row index, which points to the beginning of the
          submatrix which is to be operated on.
  JA      (global input) INTEGER
          A's global column index, which points to the beginning of
          the submatrix which is to be operated on.
  DESCA   (global and local input) INTEGER array of dimension DLEN_.
          The array descriptor for the distributed matrix A.
  B       (local input) DOUBLE PRECISION pointer into the local memory
          to an array of dimension (LLD_B, LOCc(JB+N-1)). On entry,
          this array contains the local pieces of the triangular factor
          from the Cholesky factorization of sub( B ), as returned by
          PDPOTRF.
  IB      (global input) INTEGER
          B's global row index, which points to the beginning of the
          submatrix which is to be operated on.
  JB      (global input) INTEGER
          B's global column index, which points to the beginning of
          the submatrix which is to be operated on.
  DESCB   (global and local input) INTEGER array of dimension DLEN_.
          The array descriptor for the distributed matrix B.
  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.
  =====================================================================
     .. Parameters ..

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

 
001        SUBROUTINE PDSYGS2( IBTYPE , UPLO , N , A , IA , JA , DESCA , B , IB , JB ,
002       $DESCB , INFO )
003  
004  *     -- ScaLAPACK 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 UPLO
011        INTEGER IA , IB , IBTYPE , INFO , JA , JB , N
012        INTEGER BLOCK_CYCLIC_2D , DLEN_ , DTYPE_ , CTXT_ , M_ , N_ ,
013       $MB_ , NB_ , RSRC_ , CSRC_ , LLD_
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        DOUBLE PRECISION ONE , HALF
018        PARAMETER( ONE = 1.0D + 0 , HALF = 0.5D + 0 )
019  *     ..
020  *     .. Local Scalars ..
021        LOGICAL UPPER
022        INTEGER IACOL , IAROW , IBCOL , IBROW , ICOFFA , ICOFFB ,
023       $ICTXT , IIA , IIB , IOFFA , IOFFB , IROFFA , IROFFB ,
024       $JJA , JJB , K , LDA , LDB , MYCOL , MYROW , NPCOL ,
025       $NPROW
026        DOUBLE PRECISION AKK , BKK , CT
027  *     ..
028  *     .. External Subroutines ..
029        EXTERNAL BLACS_EXIT , BLACS_GRIDINFO , CHK1MAT , DAXPY ,
030       $DSCAL , DSYR2 , DTRMV , DTRSV , INFOG2L , PXERBLA
031  *     ..
032  *     .. Intrinsic Functions ..
033        INTRINSIC MOD
034  *     ..
035  *     .. External Functions ..
036        LOGICAL LSAME
037        INTEGER INDXG2P
038        EXTERNAL LSAME , INDXG2P
039  *     ..
040  *     .. Executable Statements ..
041  *     This is just to keep ftnchek happy
042        IF( BLOCK_CYCLIC_2D*CSRC_*CTXT_*DLEN_*DTYPE_*LLD_*MB_*M_*NB_*N_*
043       $    RSRC_.LT.0 )RETURN
044  
045  *         Get grid parameters
046  
047            ICTXT = DESCA( CTXT_ )
048            CALL BLACS_GRIDINFO( ICTXT , NPROW , NPCOL , MYROW , MYCOL )
049  
050  *         Test the input parameters.
051  
052            INFO = 0
053            IF( NPROW.EQ. - 1 ) THEN
054                INFO = - ( 700 + CTXT_ )
055            ELSE
056                UPPER = LSAME( UPLO , 'U' )
057                CALL CHK1MAT( N , 3 , N , 3 , IA , JA , DESCA , 7 , INFO )
058                CALL CHK1MAT( N , 3 , N , 3 , IB , JB , DESCB , 11 , INFO )
059                IF( INFO.EQ.0 ) THEN
060                    IAROW = INDXG2P( IA , DESCA( MB_ ) , MYROW , DESCA( RSRC_ ) ,
061       $            NPROW )
062                    IBROW = INDXG2P( IB , DESCB( MB_ ) , MYROW , DESCB( RSRC_ ) ,
063       $            NPROW )
064                    IACOL = INDXG2P( JA , DESCA( NB_ ) , MYCOL , DESCA( CSRC_ ) ,
065       $            NPCOL )
066                    IBCOL = INDXG2P( JB , DESCB( NB_ ) , MYCOL , DESCB( CSRC_ ) ,
067       $            NPCOL )
068                    IROFFA = MOD( IA - 1 , DESCA( MB_ ) )
069                    ICOFFA = MOD( JA - 1 , DESCA( NB_ ) )
070                    IROFFB = MOD( IB - 1 , DESCB( MB_ ) )
071                    ICOFFB = MOD( JB - 1 , DESCB( NB_ ) )
072                    IF( IBTYPE.LT.1 .OR. IBTYPE.GT.3 ) THEN
073                        INFO = - 1
074                    ELSE IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO , 'L' ) ) THEN
075                        INFO = - 2
076                    ELSE IF( N.LT.0 ) THEN
077                        INFO = - 3
078                    ELSE IF( N + ICOFFA.GT.DESCA( NB_ ) ) THEN
079                        INFO = - 3
080                    ELSE IF( IROFFA.NE.0 ) THEN
081                        INFO = - 5
082                    ELSE IF( ICOFFA.NE.0 ) THEN
083                        INFO = - 6
084                    ELSE IF( DESCA( MB_ ).NE.DESCA( NB_ ) ) THEN
085                        INFO = - ( 700 + NB_ )
086                    ELSE IF( IROFFB.NE.0 .OR. IBROW.NE.IAROW ) THEN
087                        INFO = - 9
088                    ELSE IF( ICOFFB.NE.0 .OR. IBCOL.NE.IACOL ) THEN
089                        INFO = - 10
090                    ELSE IF( DESCB( MB_ ).NE.DESCA( MB_ ) ) THEN
091                        INFO = - ( 1100 + MB_ )
092                    ELSE IF( DESCB( NB_ ).NE.DESCA( NB_ ) ) THEN
093                        INFO = - ( 1100 + NB_ )
094                    ELSE IF( ICTXT.NE.DESCB( CTXT_ ) ) THEN
095                        INFO = - ( 1100 + CTXT_ )
096                    END IF
097                END IF
098            END IF
099  
100            IF( INFO.NE.0 ) THEN
101                CALL PXERBLA( ICTXT , 'PDSYGS2' , - INFO )
102                CALL BLACS_EXIT( ICTXT )
103                RETURN
104            END IF
105  
106  *         Quick return if possible
107  
108            IF( N.EQ.0 .OR.( MYROW.NE.IAROW .OR. MYCOL.NE.IACOL ) )
109       $        RETURN
110  
111  *             Compute local information
112  
113                LDA = DESCA( LLD_ )
114                LDB = DESCB( LLD_ )
115                CALL INFOG2L( IA , JA , DESCA , NPROW , NPCOL , MYROW , MYCOL , IIA , JJA ,
116       $        IAROW , IACOL )
117                CALL INFOG2L( IA , JA , DESCA , NPROW , NPCOL , MYROW , MYCOL , IIB , JJB ,
118       $        IBROW , IBCOL )
119  
120                IF( IBTYPE.EQ.1 ) THEN
121  
122                    IF( UPPER ) THEN
123  
124                        IOFFA = IIA + JJA*LDA
125                        IOFFB = IIB + JJB*LDB
126  
127  *                     Compute inv(U')*sub( A )*inv(U)
128  
129                        DO 10 K = 1 , N
130  
131  *                         Update the upper triangle of
132  *                         A(ia + k - 1 : ia + n - a , ia + k - 1 : ia + n - 1)
133  
134                            AKK = A( IOFFA - LDA )
135                            BKK = B( IOFFB - LDB )
136                            AKK = AKK / BKK**2
137                            A( IOFFA - LDA ) = AKK
138                            IF( K.LT.N ) THEN
139                                CALL DSCAL( N - K , ONE / BKK , A( IOFFA ) , LDA )
140                                CT = - HALF*AKK
141                                CALL DAXPY( N - K , CT , B( IOFFB ) , LDB , A( IOFFA ) ,
142       $                        LDA )
143                                CALL DSYR2( UPLO , N - K , - ONE , A( IOFFA ) , LDA ,
144       $                        B( IOFFB ) , LDB , A( IOFFA + 1 ) , LDA )
145                                CALL DAXPY( N - K , CT , B( IOFFB ) , LDB , A( IOFFA ) ,
146       $                        LDA )
147                                CALL DTRSV( UPLO , 'Transpose' , 'Non - unit' , N - K ,
148       $                        B( IOFFB + 1 ) , LDB , A( IOFFA ) , LDA )
149                            END IF
150  
151  *                         A( IOFFA ) -> A( K , K + 1 )
152  *                         B( IOFFB ) -> B( K , K + 1 )
153  
154                            IOFFA = IOFFA + LDA + 1
155                            IOFFB = IOFFB + LDB + 1
156  
157     10                 CONTINUE
158  
159                    ELSE
160  
161                        IOFFA = IIA + 1 + ( JJA - 1 )*LDA
162                        IOFFB = IIB + 1 + ( JJB - 1 )*LDB
163  
164  *                     Compute inv(L)*sub( A )*inv(L')
165  
166                        DO 20 K = 1 , N
167  
168  *                         Update the lower triangle of
169  *                         A(ia + k - 1 : ia + n - a , ia + k - 1 : ia + n - 1)
170  
171                            AKK = A( IOFFA - 1 )
172                            BKK = B( IOFFB - 1 )
173                            AKK = AKK / BKK**2
174                            A( IOFFA - 1 ) = AKK
175  
176                            IF( K.LT.N ) THEN
177                                CALL DSCAL( N - K , ONE / BKK , A( IOFFA ) , 1 )
178                                CT = - HALF*AKK
179                                CALL DAXPY( N - K , CT , B( IOFFB ) , 1 , A( IOFFA ) , 1 )
180                                CALL DSYR2( UPLO , N - K , - ONE , A( IOFFA ) , 1 ,
181       $                        B( IOFFB ) , 1 , A( IOFFA + LDA ) , LDA )
182                                CALL DAXPY( N - K , CT , B( IOFFB ) , 1 , A( IOFFA ) , 1 )
183                                CALL DTRSV( UPLO , 'No transpose' , 'Non - unit' , N - K ,
184       $                        B( IOFFB + LDB ) , LDB , A( IOFFA ) , 1 )
185                            END IF
186  
187  *                         A( IOFFA ) -> A( K + 1 , K )
188  *                         B( IOFFB ) -> B( K + 1 , K )
189  
190                            IOFFA = IOFFA + LDA + 1
191                            IOFFB = IOFFB + LDB + 1
192  
193     20                 CONTINUE
194  
195                    END IF
196  
197                ELSE
198  
199                    IF( UPPER ) THEN
200  
201                        IOFFA = IIA + ( JJA - 1 )*LDA
202                        IOFFB = IIB + ( JJB - 1 )*LDB
203  
204  *                     Compute U*sub( A )*U'
205  
206                        DO 30 K = 1 , N
207  
208  *                         Update the upper triangle of A(ia : ia + k - 1 , ja : ja + k - 1)
209  
210                            AKK = A( IOFFA + K - 1 )
211                            BKK = B( IOFFB + K - 1 )
212                            CALL DTRMV( UPLO , 'No transpose' , 'Non - unit' , K - 1 ,
213       $                    B( IIB + ( JJB - 1 )*LDB ) , LDB , A( IOFFA ) , 1 )
214                            CT = HALF*AKK
215                            CALL DAXPY( K - 1 , CT , B( IOFFB ) , 1 , A( IOFFA ) , 1 )
216                            CALL DSYR2( UPLO , K - 1 , ONE , A( IOFFA ) , 1 , B( IOFFB ) , 1 ,
217       $                    A( IIA + ( JJA - 1 )*LDA ) , LDA )
218                            CALL DAXPY( K - 1 , CT , B( IOFFB ) , 1 , A( IOFFA ) , 1 )
219                            CALL DSCAL( K - 1 , BKK , A( IOFFA ) , 1 )
220                            A( IOFFA + K - 1 ) = AKK*BKK**2
221  
222  *                         A( IOFFA ) -> A( 1 , K )
223  *                         B( IOFFB ) -> B( 1 , K )
224  
225                            IOFFA = IOFFA + LDA
226                            IOFFB = IOFFB + LDB
227  
228     30                 CONTINUE
229  
230                    ELSE
231  
232                        IOFFA = IIA + ( JJA - 1 )*LDA
233                        IOFFB = IIB + ( JJB - 1 )*LDB
234  
235  *                     Compute L'*sub( A )*L
236  
237                        DO 40 K = 1 , N
238  
239  *                         Update the lower triangle of A(ia : ia + k - 1 , ja : ja + k - 1)
240  
241                            AKK = A( IOFFA + ( K - 1 )*LDA )
242                            BKK = B( IOFFB + ( K - 1 )*LDB )
243                            CALL DTRMV( UPLO , 'Transpose' , 'Non - unit' , K - 1 ,
244       $                    B( IIB + ( JJB - 1 )*LDB ) , LDB , A( IOFFA ) ,
245       $                    LDA )
246                            CT = HALF*AKK
247                            CALL DAXPY( K - 1 , CT , B( IOFFB ) , LDB , A( IOFFA ) , LDA )
248                            CALL DSYR2( UPLO , K - 1 , ONE , A( IOFFA ) , LDA , B( IOFFB ) ,
249       $                    LDB , A( IIA + ( JJA - 1 )*LDA ) , LDA )
250                            CALL DAXPY( K - 1 , CT , B( IOFFB ) , LDB , A( IOFFA ) , LDA )
251                            CALL DSCAL( K - 1 , BKK , A( IOFFA ) , LDA )
252                            A( IOFFA + ( K - 1 )*LDA ) = AKK*BKK**2
253  
254  *                         A( IOFFA ) -> A( K , 1 )
255  *                         B( IOFFB ) -> B( K , 1 )
256  
257                            IOFFA = IOFFA + 1
258                            IOFFB = IOFFB + 1
259  
260     40                 CONTINUE
261  
262                    END IF
263  
264                END IF
265  
266                RETURN
267  
268  *             End of PDSYGS2
269  
270            END