![]() |
ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation. |
Generate and return the Dense rank of the input scalar string or contiguous
array
of rank 1
in ascending order or in the order specified by the input procedure isSorted()
using the Quicksort algorithm such that array(rank)
will be in ascending order (or in the requested order as specified by isSorted()
.
More...
Generate and return the Dense rank of the input scalar string or contiguous
array
of rank 1
in ascending order or in the order specified by the input procedure isSorted()
using the Quicksort algorithm such that array(rank)
will be in ascending order (or in the requested order as specified by isSorted()
.
This kind of ranking of values is widely known as dense (1223
) ranking.
In Dense ranking, items that compare equally receive the same ranking number, and the next items receive the immediately following ranking number.
Equivalently, the ranking number of each item is 1
plus the number of items ranked above it that are distinct with respect to the ranking order.
Thus if A ranks ahead of B and C (which compare equal) which are both ranked ahead of D, then A gets ranking number 1 (first), B gets ranking number 2
(joint second), C also gets ranking number 2
(joint second) and D gets ranking number 3
(Third).
That is, if A < B == C < D
, then the sequence ABCD
has the Dense ranking 1223
.
Dense ranking effective factorizes the array into classes of unique values.
Therefore, the Dense rank of each element of the array is simply its class level.
[in] | array | : The input contiguous array of rank 1 of either
|
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 sorting condition within isSorted() , otherwise, it is .false. .If array is a Fortran string (i.e., a scalar character ), then both input arguments to isSorted() are single character(1,SKG) where SKG is the kind of array .The following illustrates the generic interface of isSorted() when the rank of the input array is 1 , 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 RK The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati... Definition: pm_kind.F90:543 integer, parameter LK The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(.... Definition: pm_kind.F90:541 integer, parameter CK The default complex kind in the ParaMonte library: real64 in Fortran, c_double_complex in C-Fortran I... Definition: pm_kind.F90:542 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 integer, parameter SK The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero... Definition: pm_kind.F90:539 TYPE(KIND) represents the type and kind of the input argument array , which can be one of the following, character(*, SK) , intent(in) :: a, b
integer(IK) , intent(in) :: a, b
logical(LK) , intent(in) :: a, b
complex(CK) , intent(in) :: a, b
real(RK) , intent(in) :: a, b
type(css_type) , intent(in) :: a, b
type(css_pdt(SK)) , 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 kind type parameter that is supported by the processor.The following illustrates the generic interface of isSorted() when the input array is a scalar string, function isSorted(a,b) result (sorted)
character(1,SKG), intent(in) :: a, b
logical(LK) :: sorted
end function
SKG represents the kind of the input string argument array .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 .) |
rank(1:size(array)
: The output contiguous
array of rank 1
of type integer
of default kind IK containing the ranks of the corresponding elements of array
.rank
matches that of array
(or its length type parameter if array
is a scalar string).rank(i)
as the Dense rank of the i
th element of array
.
Possible calling interfaces ⛓
isSorted()
, if present, must be such that isSorted() .and. .not. isSorted()
is equivalent to an equality check for two elements of the input array
. This equality check is used to identify ties within the Standard ranking of the input array
.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.impure
when the input argument isSorted
is present.
Example usage ⛓
ifort
compiler ⛓ ifort
compiler ⛓ gfortran
compiler ⛓ ifort
version 2021.5
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 623 of file pm_arrayRank.F90.