Generate and return an array of size two containing the minimum and maximum values of a sequence of values in the first and second elements, respectively.
More...
Generate and return an array of size two containing the minimum and maximum values of a sequence of values in the first and second elements, respectively.
Note that complex values are compared lexicographically.
However, when the input sequence is a scalar string, the individual characters comprise the elements/values that are compared against each other.
See pm_complexCompareLex and pm_container for more information on the relevant lexical comparison operators.
Also, note that a logical .false.
is less than .true.
in this module.
- Parameters
-
[in] | array | : The input scalar sequence of,
-
type
character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) of arbitrary len type-parameter,
or an array of,
-
type
character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) of arbitrary len type-parameter,
-
type
integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64),
-
type
logical of kind any supported by the processor (e.g., LK),
-
type
complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128),
-
type
real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
-
type css_pdt of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) or
-
type css_type of default kind SK,
containing the values whose lexicographic minimum and maximum values are to be found.
|
- Returns
minMaxVal
: The output scalar of,
-
type
character
of length 2
of the same kind as the input scalar array
rank 0
of type character
,
or otherwise, vector of shape (1:2)
of the same type and kind (and length-type parameter) as the input array
of rank 1
, containing minval(array)
in the first element and `maxval(array) in the second element.
-
If the input
array
is a scalar of type character
of arbitrary length-type parameter, then minMaxVal(1)
will be set to the largest value for the corresponding character
kind in the processor collating sequence.
-
If the input
array
is a vector of size zero, then minMaxVal(1)
will be set to the largest value for the kind of minMaxVal(1)
.
-
If the input
array
is a vector of containers, then the val
component of minMaxVal(1)
will remain unallocated on output.
-
If the input
array
is a scalar of type character
of arbitrary length-type parameter, then minMaxVal(2)
will be set to the smallest value for the corresponding character
kind in the processor collating sequence.
-
If the input
array
is a vector of size zero, then minMaxVal(2)
will be set to the smallest value for the kind of minMaxVal(2)
.
-
If the input
array
is a vector of containers, then the val
component of minMaxVal(2)
will remain unallocated on output.
Possible calling interfaces ⛓
!
Generate and return an array of size two containing the minimum and maximum values of a sequence of v...
This module contains procedures and generic interfaces for finding the minimum and maximum of two inp...
- Note
- The procedures under this generic interface are particularly useful in combination with procedures of pm_arrayMembership and similar interfaces.
- See also
- setMinMaxVal
pm_arrayMembership
pm_mathMinMax
Example usage ⛓
10 type(display_type) :: disp
21 character(:,TKG),
allocatable :: array
22 character(
1,TKG) :: minmax(
2)
24 call disp%show(
"array = 'ParaMonte is a Machine Learning Library.'")
25 array
= 'ParaMonte is a Machine Learning Library.'
27 call disp%show( array , deliml
= SK_
"""" )
28 call disp%show(
"minmax = getMinMaxVal(array)")
31 call disp%show( minmax , deliml
= SK_
"""" )
32 call disp%show(
"minmax = getMinMaxVal(array(1:0))")
35 call disp%show( minmax , deliml
= SK_
"""" )
36 call disp%show(
"minmax(1) == char(0)")
37 call disp%show( minmax(
1)
== char(
0) )
49 character(
10,TKG),
allocatable :: array(:)
50 character(
10,TKG) :: minmax(
2)
52 call disp%show(
'array = [character(10,TKG) :: "ParaMonte", "is", "a", "Monte", "Carlo", "Library."]')
53 array
= [
character(
10,TKG) ::
"ParaMonte",
"is",
"a",
"Monte",
"Carlo",
"Library."]
55 call disp%show( array , deliml
= SK_
"""" )
56 call disp%show(
"minmax = getMinMaxVal(array)")
59 call disp%show( minmax , deliml
= SK_
"""" )
60 call disp%show(
"minmax = getMinMaxVal(array(1:0))")
63 call disp%show( minmax , deliml
= SK_
"""" )
76 type(css_type),
allocatable :: array(:)
77 type(css_type) :: minmax(
2)
79 call disp%show(
'array = css_type([character(10,TKG) :: "ParaMonte", "is", "a", "Monte", "Carlo", "Library."])')
80 array
= css_type([
character(
10,TKG) ::
"ParaMonte",
"is",
"a",
"Monte",
"Carlo",
"Library."])
82 call disp%show( array , deliml
= SK_
"""" )
83 call disp%show(
"minmax = getMinMaxVal(array)")
86 call disp%show( minmax , deliml
= SK_
"""" )
87 call disp%show(
"minmax = getMinMaxVal(array(1:0))")
89 call disp%show(
"[allocated(minmax(1)%val), allocated(minmax(2)%val)]")
90 call disp%show( [
allocated(minmax(
1)
%val),
allocated(minmax(
2)
%val)] )
102 integer(TKG),
allocatable :: array(:)
103 integer(TKG) :: minmax(
2)
105 call disp%show(
'array = getUnifRand(-9, 9, getUnifRand(3_IK, 9_IK))')
109 call disp%show(
"minmax = getMinMaxVal(array)")
113 call disp%show(
"minmax = getMinMaxVal(array(1:0))")
128 logical(TKG),
allocatable :: array(:)
129 logical(TKG) :: minmax(
2)
131 call disp%show(
'array = getUnifRand(.false., .true., getUnifRand(3_IK, 9_IK))')
135 call disp%show(
"minmax = getMinMaxVal(array)")
139 call disp%show(
"minmax = getMinMaxVal(array(1:0))")
154 complex(TKG),
allocatable :: array(:)
155 complex(TKG) :: minmax(
2)
157 call disp%show(
'array = getUnifRand((-9., -9.), (9., 9.), getUnifRand(3_IK, 9_IK))')
161 call disp%show(
"minmax = getMinMaxVal(array)")
165 call disp%show(
"minmax = getMinMaxVal(array(1:0))")
180 real(TKG),
allocatable :: array(:)
181 real(TKG) :: minmax(
2)
183 call disp%show(
'array = getUnifRand(-9, 9, getUnifRand(3_IK, 9_IK))')
187 call disp%show(
"minmax = getMinMaxVal(array)")
191 call disp%show(
"minmax = getMinMaxVal(array(1:0))")
Generate and return a scalar or a contiguous array of rank 1 of length s1 of randomly uniformly distr...
This is a generic method of the derived type display_type with pass attribute.
This is a generic method of the derived type display_type with pass attribute.
This module contains the derived types for generating allocatable containers of scalar,...
This module contains classes and procedures for computing various statistical quantities related to t...
This module contains classes and procedures for input/output (IO) or generic display operations on st...
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter CKS
The single-precision complex kind in Fortran mode. On most platforms, this is a 32-bit real kind.
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
integer, parameter RKS
The single-precision real kind in Fortran mode. On most platforms, this is an 32-bit real kind.
This is the css_type type for generating instances of container of scalar of string objects.
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example output ⛓
7array
= 'ParaMonte is a Machine Learning Library.'
9"ParaMonte is a Machine Learning Library."
25array
= [
character(
10,TKG) ::
"ParaMonte",
"is",
"a",
"Monte",
"Carlo",
"Library."]
27"ParaMonte ",
"is ",
"a ",
"Monte ",
"Carlo ",
"Library. "
41array
= css_type([
character(
10,TKG) ::
"ParaMonte",
"is",
"a",
"Monte",
"Carlo",
"Library."])
43"ParaMonte",
"is",
"a",
"Monte",
"Carlo",
"Library."
48[
allocated(minmax(
1)
%val),
allocated(minmax(
2)
%val)]
65+2147483647,
-2147483647
75T, F, T, T, T, T, F, F, T
91(
-4.97219944,
+8.86237335), (
-7.84681320,
+1.67644095), (
-2.73289871,
+5.03000450), (
+1.16910291,
-6.24009705), (
+8.76364326,
+4.57276535), (
-5.35354424,
-6.41055298), (
+4.72480679,
-3.13598633), (
+8.43589401,
+1.28488851), (
+0.329421043,
-4.44264793)
94(
-7.84681320,
+1.67644095), (
+8.76364326,
+4.57276535)
97(
+0.340282347E+39,
+0.340282347E+39), (
-0.340282347E+39,
-0.340282347E+39)
107+6.00000000,
-9.00000000,
-1.00000000,
-9.00000000,
-8.00000000,
+7.00000000,
+0.00000000,
-9.00000000,
+4.00000000
110-9.00000000,
+7.00000000
113+0.340282347E+39,
-0.340282347E+39
- Test:
- test_pm_arrayMinMax
- Todo:
- Low Priority: This generic interface can be expanded to include the possibility of passing user-defined custom comparison.
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.
-
If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
-
If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.
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.
- Copyright
- Computational Data Science Lab
- Author:
- Amir Shahmoradi, Thursday 1:45 AM, August 22, 2019, Dallas, TX
Definition at line 130 of file pm_arrayMinMax.F90.