Routine: SLASORTE()  File: SRC\slasorte.f

 
 
# lines: 145
  # code: 145
  # comment: 0
  # blank:0
# Variables:10
# Callers:0
# Callings:0
# Words:77
# Keywords:61
 

 

..
     .. Array Arguments ..
     ..
  Purpose
  =======
  SLASORTE sorts eigenpairs so that real eigenpairs are together and
    complex are together.  This way one can employ 2x2 shifts easily
    since every 2nd subdiagonal is guaranteed to be zero.
  This routine does no parallel work.
  Arguments
  =========
  S       (local input/output) REAL array, dimension LDS
          On entry, a matrix already in Schur form.
          On exit, the diagonal blocks of S have been rewritten to pair
             the eigenvalues.  The resulting matrix is no longer
             similar to the input.
  LDS     (local input) INTEGER
          On entry, the leading dimension of the local array S.
          Unchanged on exit.
  J       (local input) INTEGER
          On entry, the order of the matrix S.
          Unchanged on exit.
  OUT     (local input/output) REAL array, dimension Jx2
          This is the work buffer required by this routine.
  INFO    (local input) INTEGER
          This is set if the input matrix had an odd number of real
          eigenvalues and things couldn't be paired or if the input
           matrix S was not originally in Schur form.
          0 indicates successful completion.
  Implemented by:  G. Henry, November 17, 1996
  =====================================================================
     .. Parameters ..

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

 
001        SUBROUTINE SLASORTE( S , LDS , J , OUT , INFO )
002  
003  *     -- ScaLAPACK routine(version 1.7) --
004  *     University of Tennessee , Knoxville , Oak Ridge National Laboratory ,
005  *     and University of California , Berkeley.
006  *     December 31 , 1998
007  
008  *     .. Scalar Arguments ..
009        INTEGER INFO , J , LDS
010        REAL ZERO
011        PARAMETER( ZERO = 0.0E + 0 )
012  *     ..
013  *     .. Local Scalars ..
014        INTEGER BOT , I , LAST , TOP
015  *     ..
016  *     .. Intrinsic Functions ..
017        INTRINSIC MOD
018  *     ..
019  *     .. Executable Statements ..
020  
021        LAST = J
022        TOP = 1
023        BOT = J
024        INFO = 0
025        DO 10 I = J - 1 , 1 , - 1
026            IF( S( I + 1 , I ).EQ.ZERO ) THEN
027                IF( LAST - I.EQ.2 ) THEN
028                    OUT( BOT - 1 , 1 ) = S( I + 1 , I + 1 )
029                    OUT( BOT , 2 ) = S( I + 2 , I + 2 )
030                    OUT( BOT - 1 , 2 ) = S( I + 1 , I + 2 )
031                    OUT( BOT , 1 ) = S( I + 2 , I + 1 )
032                    BOT = BOT - 2
033                END IF
034                IF( LAST - I.EQ.1 ) THEN
035                    IF( MOD( TOP , 2 ).EQ.1 ) THEN
036  
037  *                     FIRST OF A PAIR
038  
039                        IF(( I.EQ.J - 1 ) .OR.( I.EQ.1 ) ) THEN
040                            OUT( TOP , 1 ) = S( I + 1 , I + 1 )
041                        ELSE
042                            OUT( TOP , 1 ) = S( I + 1 , I + 1 )
043                        END IF
044                        OUT( TOP , 2 ) = ZERO
045                    ELSE
046  
047  *                     SECOND OF A PAIR
048  
049                        IF(( I.EQ.J - 1 ) .OR.( I.EQ.1 ) ) THEN
050                            OUT( TOP , 2 ) = S( I + 1 , I + 1 )
051                        ELSE
052                            OUT( TOP , 2 ) = S( I + 1 , I + 1 )
053                        END IF
054                        OUT( TOP , 1 ) = ZERO
055                    END IF
056                    TOP = TOP + 1
057                END IF
058                IF( LAST - I.GT.2 ) THEN
059                    INFO = I
060                    RETURN
061                END IF
062                LAST = I
063            END IF
064     10 CONTINUE
065        IF( LAST.EQ.2 ) THEN
066  
067  *         GRAB LAST DOUBLE PAIR
068  
069            OUT( BOT - 1 , 1 ) = S( 1 , 1 )
070            OUT( BOT , 2 ) = S( 2 , 2 )
071            OUT( BOT - 1 , 2 ) = S( 1 , 2 )
072            OUT( BOT , 1 ) = S( 2 , 1 )
073            BOT = BOT - 2
074        END IF
075        IF( LAST.EQ.1 .and. mod(top , 2) .eq. 0 ) THEN
076  
077  *         GRAB SECOND PART OF LAST PAIR
078  
079            OUT(TOP , 2) = s(1 , 1)
080            OUT(TOP , 1) = zero
081            TOP = TOP + 1
082        END IF
083        IF( TOP - 1.NE.BOT ) THEN
084            INFO = - BOT
085            RETURN
086        END IF
087  
088  *     Overwrite the S diagonals
089  
090        DO 20 I = 1 , J , 2
091            S( I , I ) = OUT( I , 1 )
092            S( I + 1 , I ) = OUT( I + 1 , 1 )
093            S( I , I + 1 ) = OUT( I , 2 )
094            S( I + 1 , I + 1 ) = OUT( I + 1 , 2 )
095     20 CONTINUE
096  
097        RETURN
098  
099  *     End of SLASORTE
100  
101        END