Perform a quickselect on an array. Quick select finds the kth smallest number in an array. It also puts values lower than the kth on the left, and those higher on the right This makes it perfect for finding the median.
Use an in-place quick select on an array of numbers
Interfaced with select()
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=i32), | intent(inout) | :: | this(:) | Array to choose kth smallest from |
||
integer(kind=i32), | intent(in) | :: | k | kth smallest element |
||
integer(kind=i32) | :: | res |
Interfaced with select()
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=i64), | intent(inout) | :: | this(:) | Array to choose kth smallest from |
||
integer(kind=i32), | intent(in) | :: | k | kth smallest element |
||
integer(kind=i64) | :: | res |
Interfaced with select()
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r32), | intent(inout) | :: | this(:) | Array to choose kth smallest from |
||
integer(kind=i32), | intent(in) | :: | k | kth smallest element |
||
real(kind=r32) | :: | res |
Interfaced with select()
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r64), | intent(inout) | :: | this(:) | Array to choose kth smallest from |
||
integer(kind=i32), | intent(in) | :: | k | kth smallest element |
||
real(kind=r64) | :: | res |
Use an indirect introspection sort on an array of numbers
Interfaced with argSelect()
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=i32), | intent(in) | :: | this(:) | 1D array |
||
integer(kind=i32), | intent(inout) | :: | indx(:) | Index to choose kth smallest from |
||
integer(kind=i32), | intent(in) | :: | k | kth smallest element |
||
integer(kind=i32) | :: | res | Index of the kth smallest element |
|||
integer(kind=i32), | intent(in), | optional | :: | left | Select over the region left:right |
|
integer(kind=i32), | intent(in), | optional | :: | right | Select over the region left:right |
Interfaced with argSelect()
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=i64), | intent(in) | :: | this(:) | 1D array |
||
integer(kind=i32), | intent(inout) | :: | indx(:) | Index to choose kth smallest from |
||
integer(kind=i32), | intent(in) | :: | k | kth smallest element |
||
integer(kind=i32) | :: | res | Index of the kth smallest element |
|||
integer(kind=i32), | intent(in), | optional | :: | left | Select over the region left:right |
|
integer(kind=i32), | intent(in), | optional | :: | right | Select over the region left:right |
Interfaced with argSelect()
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r32), | intent(in) | :: | this(:) | 1D array |
||
integer(kind=i32), | intent(inout) | :: | indx(:) | Index to choose kth smallest from |
||
integer(kind=i32), | intent(in) | :: | k | kth smallest element |
||
integer(kind=i32) | :: | res | Index of the kth smallest element |
|||
integer(kind=i32), | intent(in), | optional | :: | left | Select over the region left:right |
|
integer(kind=i32), | intent(in), | optional | :: | right | Select over the region left:right |
Interfaced with argSelect()
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r64), | intent(in) | :: | this(:) | 1D array |
||
integer(kind=i32), | intent(inout) | :: | indx(:) | Index to choose kth smallest from |
||
integer(kind=i32), | intent(in) | :: | k | kth smallest element |
||
integer(kind=i32) | :: | res | Index of the kth smallest element |
|||
integer(kind=i32), | intent(in), | optional | :: | left | Select over the region left:right |
|
integer(kind=i32), | intent(in), | optional | :: | right | Select over the region left:right |