Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Fixed quicksort algorithms to properly use pre-sorted index arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Oct 25, 2021
1 parent 255a4b5 commit e6b176d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/util/util_sort.f90
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ module pure subroutine util_sort_index_dp(arr, ind)
allocate(ind(n))
ind = [(i, i=1, n)]
end if
allocate(tmparr, source=arr)
allocate(tmparr, mold=arr)
tmparr(:) = arr(ind(:))
call qsort_DP(tmparr, ind)

return
Expand Down Expand Up @@ -221,7 +222,8 @@ module pure subroutine util_sort_index_i4b(arr, ind)
allocate(ind(n))
ind = [(i, i=1, n)]
end if
allocate(tmparr, source=arr)
allocate(tmparr, mold=arr)
tmparr(:) = arr(ind(:))
call qsort_I4B(tmparr, ind)

return
Expand Down Expand Up @@ -348,7 +350,8 @@ module pure subroutine util_sort_index_sp(arr, ind)
allocate(ind(n))
ind = [(i, i=1, n)]
end if
allocate(tmparr, source=arr)
allocate(tmparr, mold=arr)
tmparr(:) = arr(ind(:))
call qsort_SP(tmparr, ind)

return
Expand Down

0 comments on commit e6b176d

Please sign in to comment.