Skip to content

Commit 1730985

Browse files
committed
consistent use of k-th smallest as suggested by jvdp1
1 parent 1ad6725 commit 1730985

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

doc/specs/stdlib_selection.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ which implements selection algorithms.
2323
## Overview of the module
2424

2525
The module `stdlib_selection` defines two generic subroutines:
26-
* `select` is used to find the kth-smallest entry of an array. The input
26+
* `select` is used to find the k-th smallest entry of an array. The input
2727
array is also modified in-place, and on return will be partially sorted
2828
such that `all(array(1:k) <= array(k)))` and `all(array(k) <= array((k+1):size(array)))`.
2929
The user can optionally specify `left` and `right` indices to constrain the search
30-
for the kth-smallest value. This can be useful if you have previously called `select`
30+
for the k-th smallest value. This can be useful if you have previously called `select`
3131
to find a smaller or larger rank (that will have led to partial sorting of
3232
`array`, thus implying some constraints on the location).
3333

@@ -131,7 +131,7 @@ end of this document shows that is the case.
131131
end program demo_select
132132
```
133133

134-
## `arg_select` - find the kth smallest value in an input array
134+
## `arg_select` - find the k-th smallest value in an input array
135135

136136
### Status
137137

@@ -156,7 +156,7 @@ Generic subroutine.
156156
`array` : shall be a rank one array of any of the types:
157157
`integer(int8)`, `integer(int16)`, `integer(int32)`, `integer(int64)`,
158158
`real(sp)`, `real(dp)`, `real(qp)`. It is an `intent(in)` argument. On input it is
159-
the array in which we search for the kth smallest entry.
159+
the array in which we search for the k-th smallest entry.
160160

161161
`indx`: shall be a rank one array with the same size as `array`, containing all integers
162162
from `1:size(array)` in any order. It is of any of the types:

src/stdlib_selection.fypp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@ contains
5555
!! quickSelect by Leon Foks, https://github.com/leonfoks/coretran
5656
!!
5757
${arraytype}$, intent(inout) :: a(:)
58-
!! Array in which we seek the kth-smallest entry.
58+
!! Array in which we seek the k-th smallest entry.
5959
!! On output it will be partially sorted such that
6060
!! `all(a(1:(k-1)) <= a(k)) .and. all(a(k) <= a((k+1):size(a)))`.
6161
${inttype}$, intent(in) :: k
62-
!! We want the kth smallest entry. E.G. `k=1` leads to
62+
!! We want the k-th smallest entry. E.G. `k=1` leads to
6363
!! `kth_smallest=min(a)`, and `k=size(a)` leads to
6464
!! `kth_smallest=max(a)`
6565
${arraytype}$, intent(out) :: kth_smallest
66-
!! On output contains the kth-smallest value of `a(:)`
66+
!! On output contains the k-th smallest value of `a(:)`
6767
${inttype}$, intent(in), optional :: left, right
6868
!! If we know that:
69-
!! the kth-smallest entry of `a` is in `a(left:right)`
69+
!! the k-th smallest entry of `a` is in `a(left:right)`
7070
!! and also that:
7171
!! `maxval(a(1:(left-1))) <= minval(a(left:right))`
7272
!! and:
@@ -163,22 +163,22 @@ contains
163163
!! quickSelect by Leon Foks, https://github.com/leonfoks/coretran
164164
!!
165165
${arraytype}$, intent(in) :: a(:)
166-
!! Array in which we seek the kth-smallest entry.
166+
!! Array in which we seek the k-th smallest entry.
167167
${inttype}$, intent(inout) :: indx(:)
168168
!! Array of indices into `a(:)`. Must contain each integer
169169
!! from `1:size(a)` exactly once. On output it will be partially
170170
!! sorted such that
171171
!! `all( a(indx(1:(k-1)))) <= a(indx(k)) ) .AND.
172172
!! all( a(indx(k)) <= a(indx( (k+1):size(a) )) )`.
173173
${inttype}$, intent(in) :: k
174-
!! We want index of the kth smallest entry. E.G. `k=1` leads to
174+
!! We want index of the k-th smallest entry. E.G. `k=1` leads to
175175
!! `a(kth_smallest) = min(a)`, and `k=size(a)` leads to
176176
!! `a(kth_smallest) = max(a)`
177177
${inttype}$, intent(out) :: kth_smallest
178-
!! On output contains the index with the kth-smallest value of `a(:)`
178+
!! On output contains the index with the k-th smallest value of `a(:)`
179179
${inttype}$, intent(in), optional :: left, right
180180
!! If we know that:
181-
!! the kth-smallest entry of `a` is in `a(indx(left:right))`
181+
!! the k-th smallest entry of `a` is in `a(indx(left:right))`
182182
!! and also that:
183183
!! `maxval(a(indx(1:(left-1)))) <= minval(a(indx(left:right)))`
184184
!! and:

0 commit comments

Comments
 (0)