Return the minimum and maximum values of the input sequence.
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.
|
[out] | vmin | : The output scalar of,
-
type
character of length 1 of the same kind as the input scalar array rank 0 of type character ,
or otherwise, of the same type and kind (and length-type parameter) as the input array of rank 1 , containing the minimum value in the sequence.
-
If the input
array is a scalar of type character of arbitrary length-type parameter, then vmin 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 vmin will be set to the largest value for the kind of vmin .
-
If the input
array is a vector of containers, then the val component of vmin will remain unallocated on output.
|
[out] | vmax | : The output scalar of,
-
type
character of length 1 of the same kind as the input scalar array rank 0 of type character ,
or otherwise, of the same type and kind (and length-type parameter) as the input array of rank 1 , containing the maximum value in the sequence.
-
If the input
array is a scalar of type character of arbitrary length-type parameter, then vmax 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 vmax will be set to the smallest value for the kind of vmax .
-
If the input
array is a vector of containers, then the val component of vmax will remain unallocated on output.
|
Possible calling interfaces ⛓
!
Return the minimum and maximum values of the input sequence.
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) :: vmin, vmax
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(
"call setMinMaxVal(array, vmin, vmax)")
31 call disp%show( [vmin, vmax] , deliml
= SK_
"""" )
32 call disp%show(
"call setMinMaxVal(array(1:0), vmin, vmax)")
35 call disp%show( [vmin, vmax] , deliml
= SK_
"""" )
49 character(
10,TKG),
allocatable :: array(:)
50 character(
10,TKG) :: vmin, vmax
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(
"call setMinMaxVal(array, vmin, vmax)")
59 call disp%show( [vmin, vmax] , deliml
= SK_
"""" )
60 call disp%show(
"call setMinMaxVal(array(1:0), vmin, vmax)")
63 call disp%show( [vmin, vmax] , deliml
= SK_
"""" )
76 type(css_type),
allocatable :: array(:)
77 type(css_type) :: vmin, vmax
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(
"call setMinMaxVal(array, vmin, vmax)")
86 call disp%show( [vmin, vmax] , deliml
= SK_
"""" )
87 call disp%show(
"call setMinMaxVal(array(1:0), vmin, vmax)")
89 call disp%show(
"[allocated(vmin%val), allocated(vmax%val)]")
90 call disp%show( [
allocated(vmin
%val),
allocated(vmax
%val)] )
102 integer(TKG),
allocatable :: array(:)
103 integer(TKG) :: vmin, vmax
105 call disp%show(
'array = getUnifRand(-9, 9, getUnifRand(3_IK, 9_IK))')
109 call disp%show(
"call setMinMaxVal(array, vmin, vmax)")
113 call disp%show(
"call setMinMaxVal(array(1:0), vmin, vmax)")
128 logical(TKG),
allocatable :: array(:)
129 logical(TKG) :: vmin, vmax
131 call disp%show(
'array = getUnifRand(.false., .true., getUnifRand(3_IK, 9_IK))')
135 call disp%show(
"call setMinMaxVal(array, vmin, vmax)")
139 call disp%show(
"call setMinMaxVal(array(1:0), vmin, vmax)")
154 complex(TKG),
allocatable :: array(:)
155 complex(TKG) :: vmin, vmax
157 call disp%show(
'array = getUnifRand((-9., -9.), (9., 9.), getUnifRand(3_IK, 9_IK))')
161 call disp%show(
"call setMinMaxVal(array, vmin, vmax)")
165 call disp%show(
"call setMinMaxVal(array(1:0), vmin, vmax)")
180 real(TKG),
allocatable :: array(:)
181 real(TKG) :: vmin, vmax
183 call disp%show(
'array = getUnifRand(-9, 9, getUnifRand(3_IK, 9_IK))')
187 call disp%show(
"call setMinMaxVal(array, vmin, vmax)")
191 call disp%show(
"call setMinMaxVal(array(1:0), vmin, vmax)")
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(vmin
%val),
allocated(vmax
%val)]
65+2147483647,
-2147483647
91(
-1.26552868,
-5.59897232), (
-7.12356806,
-0.555279732), (
+8.09062958,
-3.80038643), (
+6.18132114,
+8.99032593), (
-3.64995408,
+0.596591949), (
+8.19530106,
-1.17158794), (
+2.60075974,
+2.10302353)
94(
-7.12356806,
-0.555279732), (
+8.19530106,
-1.17158794)
97(
+0.340282347E+39,
+0.340282347E+39), (
-0.340282347E+39,
-0.340282347E+39)
107+9.00000000,
+2.00000000,
+5.00000000,
+6.00000000,
-2.00000000,
-6.00000000,
+6.00000000
110-6.00000000,
+9.00000000
113+0.340282347E+39,
-0.340282347E+39
- Test:
- test_pm_arrayMinMax
- Bug:
Status: Unresolved
Source: Intel Classic Fortran Compiler ifort
version 2021.8.0 20221119, Intel LLVM Fortran Compiler ifx
version 2023.0.0 20221201
Description: The Intel Classic Fortran Compiler ifort
and Intel LLVM Fortran Compiler ifx
as of the specified versions above cannot find the minimum and maximum of a constant empty array of type character
.
This has prevented the definition of the constants COL_SEQ_BEG
and COL_SEQ_END
in the module pm_str which are also needed in this module.
For example, the following code yields an Internal Compiler Error:
character(1), parameter :: ARRAY_EMPTY(0) = [character(1)::]
character(*), parameter :: COL_SEQ_BEG = minval(ARRAY_EMPTY,1)
end
catastrophic error: **Internal compiler error: segmentation violation signal raised**
Please report this error along with the circumstances in which it occurred in a Software Problem Report.
Note: File and line given may not be explicit cause of this error.
Remedy (as of ParaMonte Library version 2.0.0): For now, the empty arrays are constructed dynamically within the routines of this module.
- Todo:
- Critical Priority: The dynamic
character
allocation due to the bug described above must be eliminated within the implementation of this module as soon as the Intel compilers bugs are resolved.
- 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 682 of file pm_arrayMinMax.F90.