Skip to content
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

Selection algorithms #500

Merged
merged 53 commits into from
Dec 1, 2021
Merged
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ba00ab7
change name to match discussion
Aug 27, 2021
040fbcf
adding tests
Aug 27, 2021
5a0bc69
whitespace
Aug 27, 2021
20b6323
add specs
Aug 27, 2021
4f8221f
add in selection tests
Aug 27, 2021
5ebea04
whitespace
Aug 27, 2021
a5a4005
fix whitespace
Aug 27, 2021
d7d1a0b
typo
Aug 27, 2021
5305443
use error stop
Aug 27, 2021
054d7ee
make tests faster
Aug 27, 2021
5ac0033
fix example programs
Aug 27, 2021
55ecacb
get rid of precision conversion warnings
Aug 27, 2021
1128444
specs
Aug 28, 2021
f029976
fix doc
Aug 28, 2021
103b9e9
fix doc
Aug 28, 2021
648a384
fix doc
Aug 28, 2021
0c2140a
fix reference to subroutine
Aug 28, 2021
7970636
Apply some suggestions from code review by jvdp1
gareth-nx Sep 19, 2021
487c973
change "a" to "array" in documentation as suggested by jvdp1
gareth-nx Sep 19, 2021
2ffc60b
fix some remaining references to "a" by converting to "array"
gareth-nx Sep 19, 2021
3fca4ee
clearer statement of partial sorting in code doc
gareth-nx Sep 19, 2021
3195ae7
move this part of the documentation as suggested by jvdp1
gareth-nx Oct 2, 2021
0c0e020
move to coretran-style implementation to prevent any licence issues
gareth-nx Oct 2, 2021
1b0f5db
remove some warnings
gareth-nx Oct 3, 2021
af025d1
fix for out of bounds error
gareth-nx Oct 3, 2021
943a111
Changes suggested by Leon Folks
gareth-nx Oct 3, 2021
8cc6129
fix unused variable
gareth-nx Oct 3, 2021
73010e2
Apply suggestions from code review
gareth-nx Oct 3, 2021
ddec12c
Apply suggestions from code review by jvdp1
gareth-nx Oct 3, 2021
1ad6725
Further changes suggested by jvdp1
gareth-nx Oct 3, 2021
1730985
consistent use of k-th smallest as suggested by jvdp1
gareth-nx Oct 7, 2021
0be3505
update specs links and title
gareth-nx Oct 7, 2021
a6ecffa
change pth-smallest to p-th smallest, as suggested by jvdp1
gareth-nx Oct 7, 2021
533ea51
merge with master
gareth-nx Oct 7, 2021
4ab5fcf
Apply suggestions from code review by jvdp1
gareth-nx Oct 15, 2021
49d4a95
Merge branch 'master' into qsmerge
gareth-nx Nov 19, 2021
73595b3
make selection work with up-to-date stdlib
gareth-nx Nov 19, 2021
5df1b74
get the test-suite running with testdrive
gareth-nx Nov 20, 2021
f4a4dac
remove line causing bug in cmake builds
gareth-nx Nov 20, 2021
854fe4c
make dependency on stdlib_kinds clear
gareth-nx Nov 20, 2021
8a803e9
spaces not tabs
gareth-nx Nov 20, 2021
573dbfa
avoid a single logical treating many tests
gareth-nx Nov 20, 2021
c32ce17
add in the missing intent of argument k in specs. Also add real(xdp) …
gareth-nx Nov 20, 2021
b6a40e8
remove indent in specs code examples
gareth-nx Nov 24, 2021
78fa5a6
Remove Licencing section, and put acknowledgement of Leon Foks in the…
gareth-nx Nov 24, 2021
069a111
slight rewording
gareth-nx Nov 24, 2021
57500c1
Apply the more straightforward suggestions from code review
gareth-nx Nov 25, 2021
44d9804
avoid overflow in computing mid index
gareth-nx Nov 25, 2021
52f8694
add test that can catch overflow with naive mid index calculation
gareth-nx Nov 25, 2021
4b0d880
remove redundant while(.true.)
gareth-nx Nov 25, 2021
817ee30
add comment that arg_sort is not a stable sort
gareth-nx Nov 25, 2021
f486148
add statement that NaN entries in array are not supported
gareth-nx Nov 25, 2021
0f4e635
add loop labels
gareth-nx Nov 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply the more straightforward suggestions from code review
Co-authored-by: Ivan Pribec <[email protected]>
gareth-nx and ivan-pi authored Nov 25, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 57500c122bf35ea3278e975b5dd664e7fde0bd49
2 changes: 1 addition & 1 deletion doc/specs/stdlib_selection.md
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ which implements selection algorithms.
The module `stdlib_selection` defines two generic subroutines:
* `select` is used to find the k-th smallest entry of an array. The input
array is also modified in-place, and on return will be partially sorted
such that `all(array(1:k) <= array(k)))` and `all(array(k) <= array((k+1):size(array)))`.
such that `all(array(1:k) <= array(k)))` and `all(array(k) <= array((k+1):size(array)))` is true.
The user can optionally specify `left` and `right` indices to constrain the search
for the k-th smallest value. This can be useful if you have previously called `select`
to find a smaller or larger rank (that will have led to partial sorting of
7 changes: 4 additions & 3 deletions src/stdlib_selection.fypp
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ module stdlib_selection
! This code was modified from the "Coretran" implementation "quickSelect" by
! Leon Foks, https://github.com/leonfoks/coretran/tree/master/src/sorting
!
! Leon Foks gave permission to be release this code under stdlib's MIT license.
! Leon Foks gave permission to release this code under stdlib's MIT license.
! (https://github.com/fortran-lang/stdlib/pull/500#commitcomment-57418593)
!

@@ -18,7 +18,7 @@ implicit none

private

public select, arg_select
public :: select, arg_select

interface select
!! version: experimental
@@ -57,7 +57,8 @@ contains
${arraytype}$, intent(inout) :: a(:)
!! Array in which we seek the k-th smallest entry.
!! On output it will be partially sorted such that
!! `all(a(1:(k-1)) <= a(k)) .and. all(a(k) <= a((k+1):size(a)))`.
!! `all(a(1:(k-1)) <= a(k)) .and. all(a(k) <= a((k+1):size(a)))`
!! is true.
${inttype}$, intent(in) :: k
!! We want the k-th smallest entry. E.G. `k=1` leads to
!! `kth_smallest=min(a)`, and `k=size(a)` leads to
3 changes: 2 additions & 1 deletion src/tests/selection/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
### Pre-process: .fpp -> .f90 via Fypp

# Create a list of the files to be preprocessed
set(fppFiles
set(
fppFiles
test_selection.fypp
)