Routine: PSLAED3()  File: SRC\pslaed3.f

 
 
# lines: 356
  # code: 356
  # comment: 0
  # blank:0
# Variables:47
# Callers:1
# Callings:0
# Words:209
# Keywords:148
 

 

..
     .. Array Arguments ..
     ..
  Purpose
  =======
  PSLAED3 finds the roots of the secular equation, as defined by the
  values in D, W, and RHO, between 1 and K.  It makes the
  appropriate calls to SLAED4
  This code makes very mild assumptions about floating point
  arithmetic. It will work on machines with a guard digit in
  add/subtract, or on those binary machines without guard digits
  which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2.
  It could conceivably fail on hexadecimal or decimal machines
  without guard digits, but we know of none.
  Arguments
  =========
  ICTXT  (global input) INTEGER
         The BLACS context handle, indicating the global context of
         the operation on the matrix. The context itself is global.
  K      (output) INTEGER
         The number of non-deflated eigenvalues, and the order of the
         related secular equation. 0 <= K <=N.
  N      (input) INTEGER
         The dimension of the symmetric tridiagonal matrix.  N >= 0.
  NB      (global input) INTEGER
          The blocking factor used to distribute the columns of the
          matrix. NB >= 1.
  D      (input/output) REAL array, dimension (N)
         On entry, D contains the eigenvalues of the two submatrices to
         be combined.
         On exit, D contains the trailing (N-K) updated eigenvalues
         (those which were deflated) sorted into increasing order.
  DROW   (global input) INTEGER
          The process row over which the first row of the matrix D is
          distributed. 0 <= DROW < NPROW.
  DCOL   (global input) INTEGER
          The process column over which the first column of the
          matrix D is distributed. 0 <= DCOL < NPCOL.
  Q      (input/output) REAL array, dimension (LDQ, N)
         On entry, Q contains the eigenvectors of two submatrices in
         the two square blocks with corners at (1,1), (N1,N1)
         and (N1+1, N1+1), (N,N).
         On exit, Q contains the trailing (N-K) updated eigenvectors
         (those which were deflated) in its last N-K columns.
  LDQ    (input) INTEGER
         The leading dimension of the array Q.  LDQ >= max(1,NQ).
  RHO    (global input/output) REAL
         On entry, the off-diagonal element associated with the rank-1
         cut which originally split the two submatrices which are now
         being recombined.
         On exit, RHO has been modified to the value required by
         PSLAED3.
  DLAMDA (global output) REAL array, dimension (N)
         A copy of the first K eigenvalues which will be used by
         SLAED3 to form the secular equation.
  W      (global output) REAL array, dimension (N)
         The first k values of the final deflation-altered z-vector
         which will be passed to SLAED3.
  Z      (global input) REAL array, dimension (N)
         On entry, Z contains the updating vector (the last
         row of the first sub-eigenvector matrix and the first row of
         the second sub-eigenvector matrix).
         On exit, the contents of Z have been destroyed by the updating
         process.
  U     (global output) REAL array
         global dimension (N, N), local dimension (LDU, NQ).
         Q  contains the orthonormal eigenvectors of the symmetric
         tridiagonal matrix.
  LDU    (input) INTEGER
         The leading dimension of the array U.
  QBUF   (workspace) REAL array, dimension 3*N
  INDX   (workspace) INTEGER array, dimension (N)
         The permutation used to sort the contents of DLAMDA into
         ascending order.
  INDCOL (workspace) INTEGER array, dimension (N)
  INDROW (workspace) INTEGER array, dimension (N)
  INDXR (workspace) INTEGER array, dimension (N)
  INDXC (workspace) INTEGER array, dimension (N)
  CTOT   (workspace) INTEGER array, dimension( NPCOL, 4)
  NPCOL   (global input) INTEGER
          The total number of columns over which the distributed
           submatrix is distributed.
  INFO   (output) INTEGER
          = 0:  successful exit.
          < 0:  if INFO = -i, the i-th argument had an illegal value.
          > 0:  The algorithm failed to compute the ith eigenvalue.
  =====================================================================
     .. Parameters ..

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

 
001        SUBROUTINE PSLAED3( ICTXT , K , N , NB , D , DROW , DCOL , RHO , DLAMDA ,
002       $W , Z , U , LDU , BUF , INDX , INDCOL , INDROW ,
003       $INDXR , INDXC , CTOT , NPCOL , INFO )
004  
005  *     -- ScaLAPACK auxiliary routine(version 1.7) --
006  *     University of Tennessee , Knoxville , Oak Ridge National Laboratory ,
007  *     and University of California , Berkeley.
008  *     December 31 , 1998
009  
010  *     .. Scalar Arguments ..
011        INTEGER DCOL , DROW , ICTXT , INFO , K , LDU , N , NB , NPCOL
012        REAL RHO
013        REAL ONE
014        PARAMETER( ONE = 1.0E0 )
015  *     ..
016  *     .. Local Scalars ..
017        INTEGER COL , GI , I , IINFO , IIU , IPD , IU , J , JJU , JU ,
018       $KK , KL , KLC , KLR , MYCOL , MYKL , MYKLR , MYROW ,
019       $NPROW , PDC , PDR , ROW
020        REAL AUX , TEMP
021  *     ..
022  *     .. External Functions ..
023        INTEGER INDXG2L
024        REAL SLAMC3 , SNRM2
025        EXTERNAL INDXG2L , SLAMC3 , SNRM2
026  *     ..
027  *     .. External Subroutines ..
028        EXTERNAL BLACS_GRIDINFO , SCOPY , SGEBR2D , SGEBS2D ,
029       $SGERV2D , SGESD2D , SLAED4
030  *     ..
031  *     .. Intrinsic Functions ..
032        INTRINSIC MOD , SIGN , SQRT
033  *     ..
034  *     .. Executable Statements ..
035  
036  *     Test the input parameters.
037  
038        IINFO = 0
039  
040  *     Quick return if possible
041  
042        IF( K.EQ.0 )
043       $    RETURN
044  
045            CALL BLACS_GRIDINFO( ICTXT , NPROW , NPCOL , MYROW , MYCOL )
046  
047            ROW = DROW
048            COL = DCOL
049            DO 20 I = 1 , N , NB
050                DO 10 J = 0 , NB - 1
051                    INDROW( I + J ) = ROW
052                    INDCOL( I + J ) = COL
053     10         CONTINUE
054                ROW = MOD( ROW + 1 , NPROW )
055                COL = MOD( COL + 1 , NPCOL )
056     20     CONTINUE
057  
058            MYKL = CTOT( MYCOL , 1 ) + CTOT( MYCOL , 2 ) + CTOT( MYCOL , 3 )
059            KLR = MYKL / NPROW
060            IF( MYROW.EQ.DROW ) THEN
061                MYKLR = KLR + MOD( MYKL , NPROW )
062            ELSE
063                MYKLR = KLR
064            END IF
065            PDC = 1
066            COL = DCOL
067     30 CONTINUE
068        IF( MYCOL.NE.COL ) THEN
069            PDC = PDC + CTOT( COL , 1 ) + CTOT( COL , 2 ) + CTOT( COL , 3 )
070            COL = MOD( COL + 1 , NPCOL )
071            GO TO 30
072        END IF
073        PDR = PDC
074        KL = KLR + MOD( MYKL , NPROW )
075        ROW = DROW
076     40 CONTINUE
077        IF( MYROW.NE.ROW ) THEN
078            PDR = PDR + KL
079            KL = KLR
080            ROW = MOD( ROW + 1 , NPROW )
081            GO TO 40
082        END IF
083  
084        DO 50 I = 1 , K
085            DLAMDA( I ) = SLAMC3( DLAMDA( I ) , DLAMDA( I ) ) - DLAMDA( I )
086            Z( I ) = ONE
087     50 CONTINUE
088        IF( MYKLR.GT.0 ) THEN
089            KK = PDR
090            DO 80 I = 1 , MYKLR
091                CALL SLAED4( K , KK , DLAMDA , W , BUF , RHO , BUF( K + I ) , IINFO )
092                IF( IINFO.NE.0 ) THEN
093                    INFO = KK
094                END IF
095  
096  *             ..Compute part of z
097  
098                DO 60 J = 1 , KK - 1
099                    Z( J ) = Z( J )*( BUF( J ) /
100       $( DLAMDA( J ) - DLAMDA( KK ) ) )
101     60         CONTINUE
102                Z( KK ) = Z( KK )*BUF( KK )
103                DO 70 J = KK + 1 , K
104                    Z( J ) = Z( J )*( BUF( J ) /
105       $( DLAMDA( J ) - DLAMDA( KK ) ) )
106     70         CONTINUE
107                KK = KK + 1
108     80     CONTINUE
109  
110            IF( MYROW.NE.DROW ) THEN
111                CALL SCOPY( K , Z , 1 , BUF , 1 )
112                CALL SGESD2D( ICTXT , K + MYKLR , 1 , BUF , K + MYKLR , DROW , MYCOL )
113            ELSE
114                IPD = 2*K + 1
115                CALL SCOPY( MYKLR , BUF( K + 1 ) , 1 , BUF( IPD ) , 1 )
116                IF( KLR.GT.0 ) THEN
117                    IPD = MYKLR + IPD
118                    ROW = MOD( DROW + 1 , NPROW )
119                    DO 100 I = 1 , NPROW - 1
120                        CALL SGERV2D( ICTXT , K + KLR , 1 , BUF , K + KLR , ROW ,
121       $                MYCOL )
122                        CALL SCOPY( KLR , BUF( K + 1 ) , 1 , BUF( IPD ) , 1 )
123                        DO 90 J = 1 , K
124                            Z( J ) = Z( J )*BUF( J )
125     90                 CONTINUE
126                        IPD = IPD + KLR
127                        ROW = MOD( ROW + 1 , NPROW )
128    100             CONTINUE
129                END IF
130            END IF
131        END IF
132  
133        IF( MYROW.EQ.DROW ) THEN
134            IF( MYCOL.NE.DCOL .AND. MYKL.NE.0 ) THEN
135                CALL SCOPY( K , Z , 1 , BUF , 1 )
136                CALL SCOPY( MYKL , BUF( 2*K + 1 ) , 1 , BUF( K + 1 ) , 1 )
137                CALL SGESD2D( ICTXT , K + MYKL , 1 , BUF , K + MYKL , MYROW , DCOL )
138            ELSE IF( MYCOL.EQ.DCOL ) THEN
139                IPD = 2*K + 1
140                COL = DCOL
141                KL = MYKL
142                DO 120 I = 1 , NPCOL - 1
143                    IPD = IPD + KL
144                    COL = MOD( COL + 1 , NPCOL )
145                    KL = CTOT( COL , 1 ) + CTOT( COL , 2 ) + CTOT( COL , 3 )
146                    IF( KL.NE.0 ) THEN
147                        CALL SGERV2D( ICTXT , K + KL , 1 , BUF , K + KL , MYROW , COL )
148                        CALL SCOPY( KL , BUF( K + 1 ) , 1 , BUF( IPD ) , 1 )
149                        DO 110 J = 1 , K
150                            Z( J ) = Z( J )*BUF( J )
151    110                 CONTINUE
152                    END IF
153    120         CONTINUE
154                DO 130 I = 1 , K
155                    Z( I ) = SIGN( SQRT( - Z( I ) ) , W( I ) )
156    130         CONTINUE
157  
158            END IF
159        END IF
160  
161  *     Diffusion
162  
163        IF( MYROW.EQ.DROW .AND. MYCOL.EQ.DCOL ) THEN
164            CALL SCOPY( K , Z , 1 , BUF , 1 )
165            CALL SCOPY( K , BUF( 2*K + 1 ) , 1 , BUF( K + 1 ) , 1 )
166            CALL SGEBS2D( ICTXT , 'All' , ' ' , 2*K , 1 , BUF , 2*K )
167        ELSE
168            CALL SGEBR2D( ICTXT , 'All' , ' ' , 2*K , 1 , BUF , 2*K , DROW , DCOL )
169            CALL SCOPY( K , BUF , 1 , Z , 1 )
170        END IF
171  
172  *     Copy of D at the good place
173  
174        KLC = 0
175        KLR = 0
176        DO 140 I = 1 , K
177            GI = INDX( I )
178            D( GI ) = BUF( K + I )
179            COL = INDCOL( GI )
180            ROW = INDROW( GI )
181            IF( COL.EQ.MYCOL ) THEN
182                KLC = KLC + 1
183                INDXC( KLC ) = I
184            END IF
185            IF( ROW.EQ.MYROW ) THEN
186                KLR = KLR + 1
187                INDXR( KLR ) = I
188            END IF
189    140 CONTINUE
190  
191  *     Compute eigenvectors of the modified rank - 1 modification.
192  
193        IF( MYKL.NE.0 ) THEN
194            DO 180 J = 1 , MYKL
195                KK = INDXC( J )
196                JU = INDX( KK )
197                JJU = INDXG2L( JU , NB , J , J , NPCOL )
198                CALL SLAED4( K , KK , DLAMDA , W , BUF , RHO , AUX , IINFO )
199                IF( IINFO.NE.0 ) THEN
200                    INFO = KK
201                END IF
202                IF( K.EQ.1 .OR. K.EQ.2 ) THEN
203                    DO 150 I = 1 , KLR
204                        KK = INDXR( I )
205                        IU = INDX( KK )
206                        IIU = INDXG2L( IU , NB , J , J , NPROW )
207                        U( IIU , JJU ) = BUF( KK )
208    150             CONTINUE
209                    GO TO 180
210                END IF
211  
212                DO 160 I = 1 , K
213                    BUF( I ) = Z( I ) / BUF( I )
214    160         CONTINUE
215                TEMP = SNRM2( K , BUF , 1 )
216                DO 170 I = 1 , KLR
217                    KK = INDXR( I )
218                    IU = INDX( KK )
219                    IIU = INDXG2L( IU , NB , J , J , NPROW )
220                    U( IIU , JJU ) = BUF( KK ) / TEMP
221    170         CONTINUE
222    180     CONTINUE
223        END IF
224  
225    190 CONTINUE
226        RETURN
227  
228  *     End of PSLAED3
229  
230        END