-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add radix_sort #712
Add radix_sort #712
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this proposal. Here are some first general comments.
pure module subroutine int8_radix_sort(array, reverse) | ||
integer(kind=int8), dimension(:), intent(inout) :: array | ||
logical, intent(in), optional :: reverse | ||
end subroutine int8_radix_sort | ||
|
||
pure module subroutine int16_radix_sort(array, work, reverse) | ||
integer(kind=int16), dimension(:), intent(inout) :: array | ||
integer(kind=int16), dimension(:), intent(inout), target, optional :: work | ||
logical, intent(in), optional :: reverse | ||
end subroutine int16_radix_sort | ||
|
||
pure module subroutine int32_radix_sort(array, work, reverse) | ||
integer(kind=int32), dimension(:), intent(inout) :: array | ||
integer(kind=int32), dimension(:), intent(inout), target, optional :: work | ||
logical, intent(in), optional :: reverse | ||
end subroutine int32_radix_sort | ||
|
||
pure module subroutine int64_radix_sort(array, work, reverse) | ||
integer(kind=int64), dimension(:), intent(inout) :: array | ||
integer(kind=int64), dimension(:), intent(inout), target, optional :: work | ||
logical, intent(in), optional :: reverse | ||
end subroutine int64_radix_sort | ||
|
||
module subroutine sp_radix_sort(array, work, reverse) | ||
real(kind=sp), dimension(:), intent(inout), target :: array | ||
real(kind=sp), dimension(:), intent(inout), target, optional :: work | ||
logical, intent(in), optional :: reverse | ||
end subroutine sp_radix_sort | ||
|
||
module subroutine dp_radix_sort(array, work, reverse) | ||
real(kind=dp), dimension(:), intent(inout), target :: array | ||
real(kind=dp), dimension(:), intent(inout), target, optional :: work | ||
logical, intent(in), optional :: reverse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be part of a fypp
loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be part of a
fypp
loop.
stdlib defines xdp, qp
, but no int128
. While radix sort need int128
to support such width data type. Considering the difference between int8_radix_sort
and other integer types, and integer array
do not need target
attribute. I think the current version is just ok.
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Thank you for review. I have updated the code according to your comments. Here are the changes:
|
The specs file must also be updated (similar text to what is in the |
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Pending minor comments, it seems almost ready to be merged.
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: 0382 <18322825326@163.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @0382. LGTM. I'll merge it.
For build-in types, radix_sort is faster in most cases than compare based sort algorithm.