1
c-----------------------------------------------------------------------
7
c Sort the array X in the order specified by WHICH and optionally
8
c apply the permutation to the columns of the matrix A.
12
c ( WHICH, APPLY, N, X, NA, A, LDA)
15
c WHICH Character*2. (Input)
16
c 'LM' -> X is sorted into increasing order of magnitude.
17
c 'SM' -> X is sorted into decreasing order of magnitude.
18
c 'LA' -> X is sorted into increasing order of algebraic.
19
c 'SA' -> X is sorted into decreasing order of algebraic.
21
c APPLY Logical. (Input)
22
c APPLY = .TRUE. -> apply the sorted order to A.
23
c APPLY = .FALSE. -> do not apply the sorted order to A.
26
c Dimension of the array X.
28
c X Double precision array of length N. (INPUT/OUTPUT)
29
c The array to be sorted.
32
c Number of rows of the matrix A.
34
c A Double precision array of length NA by N. (INPUT/OUTPUT)
36
c LDA Integer. (INPUT)
37
c Leading dimension of A.
41
c-----------------------------------------------------------------------
46
c dswap Level 1 BLAS that swaps the contents of two vectors.
49
c Danny Sorensen Phuong Vu
50
c Richard Lehoucq CRPC / Rice University
51
c Dept. of Computational & Houston, Texas
57
c 12/15/93: Version ' 2.1'.
58
c Adapted from the sort routine in LANSO and
59
c the ARPACK code dsortr
61
c\SCCS Information: @(#)
62
c FILE: sesrt.F SID: 2.3 DATE OF SID: 4/19/96 RELEASE: 2
66
c-----------------------------------------------------------------------
68
subroutine dsesrt (which, apply, n, x, na, a, lda)
70
c %------------------%
71
c | Scalar Arguments |
72
c %------------------%
83
& x(0:n-1), a(lda, 0:n-1)
93
c %----------------------%
94
c | External Subroutines |
95
c %----------------------%
99
c %-----------------------%
100
c | Executable Statements |
101
c %-----------------------%
105
if (which .eq. 'SA') then
107
c X is sorted into decreasing order of algebraic.
110
if (igap .eq. 0) go to 9000
117
if (x(j).lt.x(j+igap)) then
121
if (apply) call dswap( na, a(1, j), 1, a(1,j+igap), 1)
131
else if (which .eq. 'SM') then
133
c X is sorted into decreasing order of magnitude.
136
if (igap .eq. 0) go to 9000
143
if (abs(x(j)).lt.abs(x(j+igap))) then
147
if (apply) call dswap( na, a(1, j), 1, a(1,j+igap), 1)
157
else if (which .eq. 'LA') then
159
c X is sorted into increasing order of algebraic.
162
if (igap .eq. 0) go to 9000
169
if (x(j).gt.x(j+igap)) then
173
if (apply) call dswap( na, a(1, j), 1, a(1,j+igap), 1)
183
else if (which .eq. 'LM') then
185
c X is sorted into increasing order of magnitude.
188
if (igap .eq. 0) go to 9000
193
if (j.lt.0) go to 120
195
if (abs(x(j)).gt.abs(x(j+igap))) then
199
if (apply) call dswap( na, a(1, j), 1, a(1,j+igap), 1)