Skip to content

Commit c32ce17

Browse files
committed
add in the missing intent of argument k in specs. Also add real(xdp) to list of supported kinds
1 parent 573dbfa commit c32ce17

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

doc/specs/stdlib_selection.md

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,29 @@ Generic subroutine.
7272

7373
`array` : shall be a rank one array of any of the types:
7474
`integer(int8)`, `integer(int16)`, `integer(int32)`, `integer(int64)`,
75-
`real(sp)`, `real(dp)`, `real(qp)`. It is an `intent(inout)` argument.
75+
`real(sp)`, `real(dp)`, `real(xdp)`, `real(qp)`. It is an `intent(inout)` argument.
7676

7777
`k`: shall be a scalar with any of the types:
7878
`integer(int8)`, `integer(int16)`, `integer(int32)`, `integer(int64)`. It
7979
is an `intent(in)` argument. We search for the `k`-th smallest entry of `array(:)`.
8080

81-
`kth_smallest`: shall be a scalar with the same type as `array`. On return it contains
82-
the k-th smallest entry of `array(:)`.
81+
`kth_smallest`: shall be a scalar with the same type as `array`. It is an
82+
`intent(out)` argument. On return it contains the k-th smallest entry of
83+
`array(:)`.
8384

84-
`left` (optional): shall be a scalar with the same type as `k`. It is an `intent(in)`
85-
argument. If specified then we assume the k-th smallest value is definitely contained
86-
in `array(left:size(array))`. If `left` is not present, the default is 1. This is typically useful if multiple calls
87-
to `select` are made, because the partial sorting of `array` implies constraints on where
88-
we need to search.
85+
`left` (optional): shall be a scalar with the same type as `k`. It is an
86+
`intent(in)` argument. If specified then we assume the k-th smallest value is
87+
definitely contained in `array(left:size(array))`. If `left` is not present,
88+
the default is 1. This is typically useful if multiple calls to `select` are
89+
made, because the partial sorting of `array` implies constraints on where we
90+
need to search.
8991

90-
`right` (optional): shall be a scalar with the same type as `k`. It is an `intent(in)`
91-
argument. If specified then we assume the k-th smallest value is definitely contained
92-
in `array(1:right)`. If `right` is not present, the default is `size(array)`. This is typically useful if multiple calls
93-
to `select` are made, because the partial sorting of `array` implies constraints on where
94-
we need to search.
92+
`right` (optional): shall be a scalar with the same type as `k`. It is an
93+
`intent(in)` argument. If specified then we assume the k-th smallest value is
94+
definitely contained in `array(1:right)`. If `right` is not present, the
95+
default is `size(array)`. This is typically useful if multiple calls to
96+
`select` are made, because the partial sorting of `array` implies constraints
97+
on where we need to search.
9598

9699
### Notes
97100

@@ -155,7 +158,7 @@ Generic subroutine.
155158

156159
`array` : shall be a rank one array of any of the types:
157160
`integer(int8)`, `integer(int16)`, `integer(int32)`, `integer(int64)`,
158-
`real(sp)`, `real(dp)`, `real(qp)`. It is an `intent(in)` argument. On input it is
161+
`real(sp)`, `real(dp)`, `real(xdp), `real(qp)`. It is an `intent(in)` argument. On input it is
159162
the array in which we search for the k-th smallest entry.
160163

161164
`indx`: shall be a rank one array with the same size as `array`, containing all integers
@@ -172,15 +175,16 @@ and on return it contains the index of the k-th smallest entry of `array(:)`.
172175

173176
`left` (optional): shall be a scalar with the same type as `k`. It is an `intent(in)`
174177
argument. If specified then we assume the k-th smallest value is definitely contained
175-
in `array(indx(left:size(array)))`. If `left` is not present, the default is 1. This is typically useful if multiple calls
176-
to `arg_select` are made, because the partial sorting of `indx` implies constraints on where
177-
we need to search.
178+
in `array(indx(left:size(array)))`. If `left` is not present, the default is 1.
179+
This is typically useful if multiple calls to `arg_select` are made, because
180+
the partial sorting of `indx` implies constraints on where we need to search.
178181

179182
`right` (optional): shall be a scalar with the same type as `k`. It is an `intent(in)`
180183
argument. If specified then we assume the k-th smallest value is definitely contained
181-
in `array(indx(1:right))`. If `right` is not present, the default is `size(array)`. This is typically useful if multiple calls
182-
to `arg_select` are made, because the reordering of `indx` implies constraints on
183-
where we need to search.
184+
in `array(indx(1:right))`. If `right` is not present, the default is
185+
`size(array)`. This is typically useful if multiple calls to `arg_select` are
186+
made, because the reordering of `indx` implies constraints on where we need to
187+
search.
184188

185189
### Notes
186190

@@ -189,7 +193,7 @@ where we need to search.
189193
While it is essential that that `indx` contains a permutation of the integers `1:size(array)`,
190194
the code does not check for this. For example if `size(array) == 4`, then we could have
191195
`indx = [4, 2, 1, 3]` or `indx = [1, 2, 3, 4]`, but not `indx = [2, 1, 2, 4]`. It is the user's
192-
responsibility to avoid such errors.
196+
responsibility to avoid such errors.
193197

194198
Selection of a single value should have runtime of O(`size(array)`), so it is
195199
asymptotically faster than sorting `array` entirely. The test program at the end of

0 commit comments

Comments
 (0)