ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation. 
Return a vector of unique values in the input array in place of the array itself.
More...
Return a vector of unique values in the input array in place of the array itself.
The uniqueness of the values can be optionally determined by the user by specifying the external input function that checks the equivalence of a pair of elements of the input array
.
Furthermore, optionally return the count of each of the unique values in the input array
, as well as the indices of occurrences of each of the unique values.
[in]  array  : The input contiguous array of shape (:) of either

[out]  unique  : The output array of the same type and kind as the input array containing all of its unique elements.

[out]  lenUnique  : The output scalar of type integer of default kind of the same type and kind as the input array containing all of its unique elements.(optional, if present, the specified arrays unique , count , index must be preallocated to the length of array .) 
[out]  count  : The output array of type integer of default kind IK containing the corresponding counts of each of the uniques elements of array in the output unique array.

[out]  index  : The output jaggedarray of type cvi_type of default kind IK each element of which contains the vector of indices of the positions of occurrences of the uniques values in array .

[in]  order  : The input integer of default kind IK.If 0 , the output array count will be not be sorted.If 1 , the output array count (and along with it, unique and index ) will be sorted in descending order.If +1 , the output array count (and along with it, unique and index ) will be sorted in ascending order.(optional, default = 0_IK ) 
iseq  : The external userspecified 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 two input arguments are equivalent (e.g., equal) according to the userdefined criterion, otherwise, it is .false. .The following illustrates the generic interface of iseq , function iseq(element1, element2) result(equivalent)
TYPE(KIND) , intent(in) :: element1, element2
logical(LK) :: equivalent
end function
This module defines the relevant Fortran kind typeparameters 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 TYPE(KIND) represents the type and kind of the input argument setA , which can be one of the following, character(*, SK), intent(in) :: element1, element2 ! when `array` is a string vector.
character(1, SK), intent(in) :: element1, element2 ! when `array` is a string scalar.
integer(IK) , intent(in) :: element1, element2
logical(LK) , intent(in) :: element1, element2
complex(CK) , intent(in) :: element1, element2
real(RK) , intent(in) :: element1, element2
integer, parameter RK The default real kind in the ParaMonte library: real64 in Fortran, c_double in CFortran Interoperati... Definition: pm_kind.F90:543 integer, parameter CK The default complex kind in the ParaMonte library: real64 in Fortran, c_double_complex in CFortran I... Definition: pm_kind.F90:542 integer, parameter IK The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in CFortran Interoper... Definition: pm_kind.F90:540 integer, parameter SK The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in CFortran Intero... Definition: pm_kind.F90:539 SK , IK , LK , CK , RK , can refer to any kind type parameter that is supported by the processor.This userdefined equivalence check is extremely useful where a userdefined equivalence test other than exact equality or identity is needed, for example, when the array elements should match only within a given threshold or, when the casesensitivity in character comparisons do not matter. In such cases, the user can define a custom equivalence criterion within the userdefined external function iseq to achieve the goal.(optional, the default equivalence operator is .eqv. if the input array is logical , otherwise == .) 
Possible calling interfaces ⛓
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 userspecified external
procedure iseq
is specified as input argument.lenUnique <= len/size(unique)
must hold for the corresponding input/output arguments.lenUnique <= len/size(index)
must hold for the corresponding input/output arguments.lenUnique <= len/size(count)
must hold for the corresponding input/output arguments.CHECK_ENABLED=1
."Fortran" == "Fortran "
yields .true.
.
Example usage ⛓
ifort
compiler ⛓ ifort
compiler ⛓ gfortran
compiler ⛓ ifort
version 2021.7 ifort
version 2021.7 on Microsoft WSL (and possibly other platforms) cannot properly call getRemapped(unique, ...)
when unique
is a contiguous character
array.lenUnique
output argument could be added to the procedures such that when it is present, the output arrays unique
and count
will not be resized from size(array)
to the correct length lenUnique
.(1:lenUnique)
of the output arrays are used for any subsequent work as only these elements are meaningful. This would, however, come with the benefit of extra efficiency.
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 3550 of file pm_arrayUnique.F90.