Generate and return .true.
if the input value val
is within a range specified by the input array-like object set(1:2)
, otherwise, return .false.
.
- Parameters
-
[in] | val | : The input scalar or vector of,
-
type
character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) or arbitrary length type parameter, or
-
type
integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64), or
-
type
logical of kind any supported by the processor (e.g., LK), or
-
type
complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128), or
-
type
real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128), or
whose (elemental) membership(s) in the set will be checked. |
[in] | set | : The input scalar of the same character type and kind as val of length-type-parameter 2 or vector of the same type and kind as val of size 2 , representing the range [set(1) : set(2)] with respect to which the (elemental) membership of val will be checked.
By convention,
-
If the input arguments are of type
character , integer , real , then the values are compared as defined by the standard.
-
If the input arguments are of type
complex , then the input values are elementally compared lexically (similar to string comparison).
-
If the input arguments are of type
logical , then .false. < .true. is assumed.
|
- Returns
member
: The output scalar or vector of the same size as the input val
, of type logical
of default kind LK.
It is .true.
if and only if the corresponding val
is within the input range specified by set
.
Possible calling interfaces ⛓
member = val .inrange. set(1:2)
member(1:size(val)) = val(:) .inrange. set(1:2)
This module contains procedures and generic interfaces for assessing whether particular value(s) or a...
- Note
- Normally, the condition
set(1) < set(2)
is expected to hold for the input set
argument, otherwise, the specified range corresponds to an empty set.
-
This generic interface offers a neat way of checking a value against a range returned by either getMinMax() or operator(.subadd.) or operator(.divmul.).
- See also
- operator(.in.)
operator(.allin.)
operator(.anyin.)
operator(.inrange.)
operator(.anyinrange.)
operator(.allinrange.)
operator(.divmul.)
operator(.subadd.)
getMinMax
setMinMax
pm_arraySearch
pm_arrayFind
Example usage ⛓
14 type(display_type) :: disp
18 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%")
19 call disp%show(
"!Check character scalar.")
20 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%")
24 character(:,SKG),
allocatable :: val, Set
29 call disp%show( val, deliml
= SKG_
"""" )
31 call disp%show( Set, deliml
= SKG_
"""" )
38 character(:,SKG),
allocatable :: val, Set
43 call disp%show( val, deliml
= SKG_
"""" )
45 call disp%show( Set, deliml
= SKG_
"""" )
52 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%")
53 call disp%show(
"!Check character array.")
54 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%")
58 character(:,SKG),
allocatable :: val
59 character(
2,SKG),
allocatable :: Set(:)
60 Set
= [
character(
2,SKG) ::
"aa",
"zz"]
64 call disp%show( val, deliml
= SKG_
"""" )
66 call disp%show( Set, deliml
= SKG_
"""" )
73 character(
9,SKG),
allocatable :: val(:)
74 character(
10,SKG),
allocatable :: Set(:)
75 Set
= [
character(
10,SKG) ::
"aa",
"zz"]
76 val
= [
character(
9,SKG) ::
"paramonte",
"ParaMonte",
"Carlo",
"carlo"]
79 call disp%show( val, deliml
= SKG_
"""" )
81 call disp%show( Set, deliml
= SKG_
"""" )
88 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%")
89 call disp%show(
"!Check integer array.")
90 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%")
94 integer(IKG),
allocatable :: val, Set(:)
98 call disp%show(
"Set = [integer(IKG) :: 1, 3]")
99 Set
= [
integer(IKG) ::
1,
3]
106 integer(IKG),
allocatable :: val(:), Set(:)
108 call disp%show(
"val = [integer(IKG) :: -1, 3, 5]")
109 val
= [
integer(IKG) ::
-1,
3,
5]
110 call disp%show(
"Set = [integer(IKG) :: 1, 3]")
111 Set
= [
integer(IKG) ::
1,
3]
118 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%")
119 call disp%show(
"!Check logical array.")
120 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%")
124 logical(LKG),
allocatable :: val, Set(:)
128 call disp%show(
"Set = [.false., .true.]")
129 Set
= [
.false.,
.true.]
136 logical(LKG),
allocatable :: val(:), Set(:)
138 call disp%show(
"val = [.false., .true., .false.]")
139 val
= [
.false.,
.true.,
.false.]
140 call disp%show(
"Set = [.true., .true.]")
141 Set
= [
.true.,
.true.]
148 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%")
149 call disp%show(
"!Check complex array.")
150 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%")
154 integer(IKG),
allocatable :: val, Set(:)
158 call disp%show(
"Set = [complex(CKG) :: (1., 0.), (1., -1.)]")
159 Set
= [
complex(CKG) :: (
1.,
0.), (
1.,
-1.)]
166 integer(IKG),
allocatable :: val(:), Set(:)
168 call disp%show(
"val = [(1., -1.), (0., -1.), (2., -1.)]")
169 val
= [(
1.,
-1.), (
0.,
-1.), (
2.,
-1.)]
170 call disp%show(
"Set = [complex(CKG) :: (1., 0.), (1., -1.)]")
171 Set
= [
complex(CKG) :: (
1.,
0.), (
1.,
-1.)]
178 call disp%show(
"!%%%%%%%%%%%%%%%%%")
179 call disp%show(
"!Check real array.")
180 call disp%show(
"!%%%%%%%%%%%%%%%%%")
184 real(RKG),
allocatable :: val, Set(:)
188 call disp%show(
"Set = [real(RKG) :: 1, 3]")
189 Set
= [
real(RKG) ::
1,
3]
196 real(RKG),
allocatable :: val(:), Set(:)
198 call disp%show(
"val = [real(RKG) :: -1, 1, 5]")
199 val
= [
real(RKG) ::
-1,
1,
5]
200 call disp%show(
"Set = [real(RKG) :: 1, 3]")
201 Set
= [
real(RKG) ::
1,
3]
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 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 RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter CK
The default complex kind in the ParaMonte library: real64 in Fortran, c_double_complex in C-Fortran I...
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...
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 ⛓
20T, T, T, T, T, T, T, T, T, F
37"paramonte",
"ParaMonte",
"Carlo ",
"carlo "
50Set
= [
integer(IKG) ::
1,
3]
55val
= [
integer(IKG) ::
-1,
3,
5]
56Set
= [
integer(IKG) ::
1,
3]
67Set
= [
.false.,
.true.]
72val
= [
.false.,
.true.,
.false.]
84Set
= [
complex(CKG) :: (
1.,
0.), (
1.,
-1.)]
89val
= [(
1.,
-1.), (
0.,
-1.), (
2.,
-1.)]
90Set
= [
complex(CKG) :: (
1.,
0.), (
1.,
-1.)]
101Set
= [
real(RKG) ::
1,
3]
106val
= [
real(RKG) ::
-1,
1,
5]
107Set
= [
real(RKG) ::
1,
3]
- Test:
- test_pm_arrayMembership
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:
- Fatemeh Bagheri, Wednesday 1:35 PM, August 11, 2021, Dallas, TX
Definition at line 924 of file pm_arrayMembership.F90.