English 中文(简体)
从Zgeev获得的Sorting eigensystem
原标题:Sorting eigensystem obtained from zgeev

I m using the Lapack routine zgeev to obtain the (complex) eigenvalues and eigenvectors of a non-symmetric complex matrix in Fortran. The resulting array of eigenvectors is in some arbitrary order. I would like to reorder both the array of eigenvalues and the corresponding columns in the matrix of eigenvectors so that the eigenvalues are in ascending order with respect to the real part of each eigenvalue. I could of course roll my own sorting routine, but I was wondering if there was already a Fortran routine somewhere that can do this for me, maybe even as part of lapack.

最佳回答

你们只能看一下z子的末端。 相关的法典范围是

*        Use Selection Sort to minimize swaps of eigenvectors
*
         DO 180 II = 2, N
            I = II - 1
            K = I
            P = D( I )
            DO 170 J = II, N
               IF( D( J ).LT.P ) THEN
                  K = J
                  P = D( J )
               END IF
  170       CONTINUE
            IF( K.NE.I ) THEN
               D( K ) = D( I )
               D( I ) = P
               CALL ZSWAP( N, Z( 1, I ), 1, Z( 1, K ), 1 )
            END IF
  180    CONTINUE

因此,我认为你必须改变比较线(但未经测试)。

Ian

问题回答

几天前,我写了字,但根据实际价值进行分类。 这是“快速启动方案”的实施。 确保你们投入你想要发挥的关键性作用。

RECURSIVE SUBROUTINE ZQSORT(N,ARRAY)
  IMPLICIT NONE
  INTEGER(4), INTENT(IN)    :: N
  COMPLEX(8), INTENT(INOUT) :: ARRAY(N)
  complex(8)                   :: PIVOT
  COMPLEX(8)                :: TEMP
  INTEGER(4)                :: LEFT,RIGHT

  IF (N.GT.1) THEN
     PIVOT=ARRAY(N/2) !INTEGER DIVISION
     LEFT=1
     RIGHT=N
     DO WHILE (LEFT.LE.RIGHT)
        DO WHILE (REAL(ARRAY(LEFT)).LT.REAL(PIVOT)) !REAL(Z) IS THE KEY USED FOR SORTING HERE
           LEFT=LEFT+1
        END DO
        DO WHILE (REAL(ARRAY(RIGHT)).GT.REAL(PIVOT))! AGAIN KEY APPEARS HERE
           RIGHT=RIGHT-1
        END DO
        IF (LEFT.LE.RIGHT) THEN
           TEMP=ARRAY(LEFT)           !
           ARRAY(LEFT) = ARRAY(RIGHT) !SWAPPING THE ELEMENTS WITH INDICES LEFT<-->RIGHT
           ARRAY(RIGHT)= TEMP         !
           LEFT = LEFT+1
           RIGHT= RIGHT-1
        END IF
        CALL ZQSORT(RIGHT,ARRAY(1:RIGHT))
        CALL ZQSORT(N-LEFT+1,ARRAY(LEFT:N))
     END DO
  END IF
  RETURN
END SUBROUTINE ZQSORT




相关问题
How do I sort enum members alphabetically in Java?

I have an enum class like the following: public enum Letter { OMEGA_LETTER("Omega"), GAMMA_LETTER("Gamma"), BETA_LETTER("Beta"), ALPHA_LETTER("Alpha"), private final String ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Linq operations against a List of Hashtables?

I m working with a set of legacy DAO code that returns an IList, where each Hashtable represents the row of a dynamically executed SQL query. For example, the List might contain the following records/...

C++ Array Sort Me

Stuck on an array sorter. Have to sort numbers from largest to smallest. I m trying two loops (one nested in the other). Here s the code: int counter=0; // inner counter int counter2=0; // outer ...

Can I Nest OrderBy in .NET?

This doesn t seem to work as I intend. VB.NET: Dim x = Model.Discussions.OrderByDescending(Function(d) d.Messages.OrderByDescending(Function(m) m.Sent).First.Sent) For Each d As Discussion In x ....

sorting elements javascript

I m looking for a way to sort my elements, but it isn t as easy as it sounds. Please let me explain My elements are grouped per 6 elements (thumbnails), each x represents a thumbnail However all ...

热门标签