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 suggestions from code review
First batch of suggestions from jvdp1

Co-authored-by: Jeremie Vandenplas <[email protected]>
gareth-nx and jvdp1 authored Oct 3, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 73010e23cd11cce0f74706aa916211fd4fb1bc69
11 changes: 5 additions & 6 deletions doc/specs/stdlib_selection.md
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ title: Selection Procedures

## Overview of selection

Suppose you wish to find the value of the kth-smallest entry in an array of size N, or
Suppose you wish to find the value of the k-th smallest entry in an array of size N, or
the index of that value. While it could be done by sorting the whole array
using `[[stdlib_sorting(module):sort(interface)]]` or
`[[stdlib_sorting(module):sort_index(interface)]]` from
@@ -31,23 +31,22 @@ for the kth-smallest value. This can be useful if you have previously called `se
to find a smaller or larger rank (that will have led to partial sorting of
`array`, thus implying some constraints on the location).

* `arg_select` is used to find the index of the kth-smallest entry of an array.
* `arg_select` is used to find the index of the k-th smallest entry of an array.
In this case the input array is not modified, but the user must provide an
input index array with the same size as `array`, having unique indices from
`1:size(array)`, which is modified instead. On return the index array is modified
such that `all(array(index(1:k)) <= array(index(k)))` and `all(array(k) <= array(k+1:size(array)))`.
The user can optionally specify `left` and `right` indices to constrain the search
for the kth-smallest value. This can be useful if you have previously called `arg_select`
for the k-th smallest value. This can be useful if you have previously called `arg_select`
to find a smaller or larger rank (that will have led to partial sorting of
`index`, thus implying some constraints on the location).

#### Licensing

The Fortran Standard Library is distributed under the MIT
License. However components of the library may be based on code with
additional licensing restrictions. In particular `select` and `arg_select`
License. It is worth noting that `select` and `arg_select`
were derived using some code from quickSelect in the Coretran library, by Leon Foks,
https://github.com/leonfoks/coretran. Leon has given permission for the code here
https://github.com/leonfoks/coretran. Leon Foks has given permission for the code here
to be released under stdlib's MIT licence.

### Specifications of the `stdlib_selection` procedures