Revision a968cb727c3b72a67d1ddc6588c5edf9c0e3723a authored by Doug Nychka on 21 April 2013, 07:56:06 UTC, committed by cran-robot on 21 April 2013, 07:56:06 UTC
1 parent 759a1e4
sortm.f
SUBROUTINE SORTM(K,ki,N)
C HEAPSORT ALGORITHM FOR SORTING ON VECTOR OF KEYS K OF LENGTH N
C J F MONAHAN TRANSCRIBED FROM KNUTH, VOL 2, PP 146-7.
C integer array ki is permuted along with K
REAL*8 K(N),KK
integer ki(N),kki
INTEGER R
IF(N.LE.1) RETURN
L=N/2+1
R=N
2 IF(L.GT.1) GO TO 1
KK=K(R)
kki= ki(R)
K(R)=K(1)
ki(R)=ki(1)
R=R-1
IF(R.EQ.1) GO TO 9
GO TO 3
1 L=L-1
KK=K(L)
kki=ki(L)
3 J=L
4 I=J
J=2*J
IF(J-R) 5,6,8
5 IF(K(J).LT.K(J+1)) J=J+1
6 IF(KK.GT.K(J)) GO TO 8
7 K(I)=K(J)
ki(I)=ki(J)
GO TO 4
8 K(I)=KK
ki(I)=kki
GO TO 2
9 K(1)=KK
ki(1)=kki
RETURN
END
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...