You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/specs/stdlib_selection.md
+40-37Lines changed: 40 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,12 @@ title: Selection Procedures
10
10
11
11
Suppose you wish to find the value of the kth-smallest entry in an array, or
12
12
the index of that value. While it could be done by sorting the whole array
13
-
using `[[stdlib_sorting(module):sort(interface)]]` or `[[stdlib_sorting(module):sort_index(interface)]]` from `[[stdlib_sorting(module)]]` and then finding the k-th
14
-
entry, that would require O(N x LOG(N)) time. However selection of a single
15
-
entry can be done in O(N) time, which is much faster for large arrays. This is
16
-
useful, for example, to quickly find the median of an array, or some other
17
-
percentile.
13
+
using `[[stdlib_sorting(module):sort(interface)]]` or
14
+
`[[stdlib_sorting(module):sort_index(interface)]]` from
15
+
`[[stdlib_sorting(module)]]` and then finding the k-th entry, that would
16
+
require O(N x LOG(N)) time. However selection of a single entry can be done in
17
+
O(N) time, which is much faster for large arrays. This is useful, for example,
18
+
to quickly find the median of an array, or some other percentile.
18
19
19
20
The Fortran Standard Library therefore provides a module, `stdlib_selection`,
20
21
which implements selection algorithms.
@@ -86,49 +87,50 @@ Experimental
86
87
87
88
##### Description
88
89
89
-
Returns the k-th smallest value of array `a(:)`, and also partially sorts `a(:)`
90
-
such that `all(a(1:k) <= a(k))` and `all(a(k) <= a((k+1):size(a)))`
90
+
Returns the k-th smallest value of `array(:)`, and also partially sorts `array(:)`
91
+
such that `all(array(1:k) <= array(k))` and `all(array(k) <= array((k+1):size(array)))`
91
92
92
93
##### Syntax
93
94
94
-
`call [[stdlib_selection(module):select(interface)]]( a, k, kth_smallest [, left, right ] )`
95
+
`call [[stdlib_selection(module):select(interface)]]( array, k, kth_smallest [, left, right ] )`
95
96
96
97
##### Class
97
98
98
99
Generic subroutine.
99
100
100
101
##### Arguments
101
102
102
-
`a` : shall be a rank one array of any of the types:
103
+
`array` : shall be a rank one array of any of the types:
0 commit comments