1 SUBROUTINE slapst( ID, N, D, INDX, INFO )
52 parameter(
SELECT = 20 )
55 INTEGER DIR, ENDD, I, ITMP, J, START, STKPNT
56 REAL D1, D2, D3, DMNMX
59 INTEGER STACK( 2, 32 )
74 IF( lsame( id,
'D' ) )
THEN
76 ELSE IF( lsame( id,
'I' ) )
THEN
81 ELSE IF( n.LT.0 )
THEN
85 CALL xerbla(
'SLAPST', -info )
102 start = stack( 1, stkpnt )
103 endd = stack( 2, stkpnt )
105 IF( endd-start.LE.
SELECT .AND. endd-start.GT.0 )
THEN
113 DO 40 i = start + 1, endd
114 DO 30 j = i, start + 1, -1
115 IF( d( indx( j ) ).GT.d( indx( j-1 ) ) )
THEN
117 indx( j ) = indx( j-1 )
129 DO 60 i = start + 1, endd
130 DO 50 j = i, start + 1, -1
131 IF( d( indx( j ) ).LT.d( indx( j-1 ) ) )
THEN
133 indx( j ) = indx( j-1 )
143 ELSE IF( endd-start.GT.
SELECT )
THEN
149 d1 = d( indx( start ) )
150 d2 = d( indx( endd ) )
151 i = ( start+endd ) / 2
156 ELSE IF( d3.LT.d2 )
THEN
164 ELSE IF( d3.LT.d1 )
THEN
180 IF( d( indx( j ) ).LT.dmnmx )
184 IF( d( indx( i ) ).GT.dmnmx )
188 indx( i ) = indx( j )
192 IF( j-start.GT.endd-j-1 )
THEN
194 stack( 1, stkpnt ) = start
195 stack( 2, stkpnt ) = j
197 stack( 1, stkpnt ) = j + 1
198 stack( 2, stkpnt ) = endd
201 stack( 1, stkpnt ) = j + 1
202 stack( 2, stkpnt ) = endd
204 stack( 1, stkpnt ) = start
205 stack( 2, stkpnt ) = j
216 IF( d( indx( j ) ).GT.dmnmx )
220 IF( d( indx( i ) ).LT.dmnmx )
224 indx( i ) = indx( j )
228 IF( j-start.GT.endd-j-1 )
THEN
230 stack( 1, stkpnt ) = start
231 stack( 2, stkpnt ) = j
233 stack( 1, stkpnt ) = j + 1
234 stack( 2, stkpnt ) = endd
237 stack( 1, stkpnt ) = j + 1
238 stack( 2, stkpnt ) = endd
240 stack( 1, stkpnt ) = start
241 stack( 2, stkpnt ) = j