ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation. |
Return the rank
th smallest (or ordered) value in the input array by first sorting its elements in ascending order (optionally only between the specified indices [lb, ub]
).
More...
Return the rank
th smallest (or ordered) value in the input array by first sorting its elements in ascending order (optionally only between the specified indices [lb, ub]
).
By default, the array will be sorted in ascending order, unless the user-specific isSorted()
external function is supplied to define a custom sorting criterion.
[out] | selection | : The output scalar of either of the same type and kind as the input array argument, containing the rank th smallest value in the input array . |
[in,out] | array | : The input/output contiguous array of shape (:) of either
rank th smallest value is to be reported as the output selection .On return, the first rank th elements of array will be sorted in ascending order or in the user-specified order as determined by the user-supplied external isSorted() argument. |
[in] | rank | : The input integer of default kind IK, representing the index of the rank th smallest value in the input array or the rank th ordered value according to the user-supplied external logical function isSorted() . |
isSorted | : The external user-specified function that takes two input scalar arguments of the same type and kind as the input array .It returns a scalar logical of default kind LK that is .true. if the first input scalar argument is sorted with respect to the second input argument according to the user-defined condition within isSorted , otherwise, it is .false. .If array is a Fortran string (i.e., an assumed-length scalar character ), then both input arguments to isSorted() are character(1,SK) of default kind SK.The following illustrates the generic interface of isSorted() , function isSorted(a,b) result (sorted)
TYPE(KIND) , intent(in) :: a, b
logical(LK) :: sorted
end function
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar... Definition: pm_kind.F90:268 integer, parameter LK The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(.... Definition: pm_kind.F90:541 integer, parameter IK The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper... Definition: pm_kind.F90:540 TYPE(KIND) is the same as the type and kind of the input argument array , which can be one of the following. character(*, SK), intent(in) :: a, b
character(1, SK), intent(in) :: a, b
type(css_type) , intent(in) :: a, b
type(css_pdt) , intent(in) :: a, b
integer(IK) , intent(in) :: a, b
real(RK) , intent(in) :: a, b
This module contains the derived types for generating allocatable containers of scalar,... Definition: pm_container.F90:113 This is the css_pdt parameterized type for generating instances of container of scalar of string obje... Definition: pm_container.F90:783 This is the css_type type for generating instances of container of scalar of string objects. Definition: pm_container.F90:191 SK , IK , LK , CK , RK ) can refer to any of the supported kinds by the processor.This user-defined equivalence check is extremely useful where a user-defined sorting criterion other than simple ascending order is needed, for example, when the case-sensitivity of an input string or array of strings is irrelevant or when sorting of the absolute values matters excluding the signs of the numbers, or when descending order is desired. In such cases, user can define a custom sorting condition within the user-defined external function isSorted to achieve the goal.(optional, the default sorting condition is ascending order, that is a < b .) | |
[in] | lb | : The optional input scalar integer of default kind IK representing the lower bound of the segment of array below which the array elements are assumed to be in ascending order, such that only the elements starting with and beyond lb require sorting.If the initial segment of the input array is ordered, specifying this lower bound will lead to better performance of the algorithm. (optional, default = 1_IK ) |
[in] | ub | : The optional input scalar integer of default kind IK representing the upper bound of the segment of array above which the array elements are assumed to be in ascending order, such that only the elements ending with and below ub require sorting.If the final segment of the input array is ordered, specifying this upper bound will lead to better performance of the algorithm. (optional, default = size(array, kind = IK) ) |
Possible calling interfaces ⛓
lb
is present as an input argument, its value must be larger than 0
and less than ub
or its default value.rank
must be larger than or equal to the specified value for lb
.ub
is present as an input argument, its value must be less than or equal to the length of array
and larger than ub
or its default value.rank
must be smaller than or equal to the specified value for ub
.CHECK_ENABLED=1
.impure
when the external
input argument isSorted()
is present
.pure
procedure(s) documented herein become impure
when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1
.pure
in release
build and impure
in debug
and testing
builds.
Example usage ⛓
ifort
compiler ⛓ ifort
compiler ⛓ gfortran
compiler ⛓
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
Definition at line 1725 of file pm_arraySelect.F90.