ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_arrayMembership::operator(.inrange.) Interface Reference

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.. More...

Detailed Description

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,
  1. If the input arguments are of type character, integer, real, then the values are compared as defined by the standard.
  2. If the input arguments are of type complex, then the input values are elementally compared lexically (similar to string comparison).
  3. 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

use pm_arrayMembership, only: operator(.inrange.)
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...
Remarks
The procedures under discussion are pure.
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

1program example
2
3 use pm_kind, only: LK
4 use pm_kind, only: SKG => SK ! All kinds are supported.
5 use pm_kind, only: IKG => IK ! All kinds are supported.
6 use pm_kind, only: LKG => LK ! All kinds are supported.
7 use pm_kind, only: CKG => CK ! All kinds are supported.
8 use pm_kind, only: RKG => RK ! All kinds are supported.
9 use pm_io, only: display_type
10 use pm_arrayMembership, only: operator(.inrange.)
11
12 implicit none
13
14 type(display_type) :: disp
15 disp = display_type(file = "main.out.F90")
16
17 call disp%skip()
18 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%")
19 call disp%show("!Check character scalar.")
20 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%")
21 call disp%skip()
22
23 block
24 character(:,SKG), allocatable :: val, Set
25 Set = "AZ"
26 val = "M"
27 call disp%skip()
28 call disp%show("val")
29 call disp%show( val, deliml = SKG_"""" )
30 call disp%show("Set")
31 call disp%show( Set, deliml = SKG_"""" )
32 call disp%show("val .inrange. Set")
33 call disp%show( val .inrange. Set )
34 call disp%skip()
35 end block
36
37 block
38 character(:,SKG), allocatable :: val, Set
39 Set = "Az"
40 val = "ParaMonte."
41 call disp%skip()
42 call disp%show("val")
43 call disp%show( val, deliml = SKG_"""" )
44 call disp%show("Set")
45 call disp%show( Set, deliml = SKG_"""" )
46 call disp%show("val .inrange. Set")
47 call disp%show( val .inrange. Set )
48 call disp%skip()
49 end block
50
51 call disp%skip()
52 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
53 call disp%show("!Check character array.")
54 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
55 call disp%skip()
56
57 block
58 character(:,SKG), allocatable :: val
59 character(2,SKG), allocatable :: Set(:)
60 Set = [character(2,SKG) :: "aa", "zz"]
61 val = "paramonte"
62 call disp%skip()
63 call disp%show("val")
64 call disp%show( val, deliml = SKG_"""" )
65 call disp%show("Set")
66 call disp%show( Set, deliml = SKG_"""" )
67 call disp%show("val .inrange. Set")
68 call disp%show( val .inrange. Set )
69 call disp%skip()
70 end block
71
72 block
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"]
77 call disp%skip()
78 call disp%show("val")
79 call disp%show( val, deliml = SKG_"""" )
80 call disp%show("Set")
81 call disp%show( Set, deliml = SKG_"""" )
82 call disp%show("val .inrange. Set")
83 call disp%show( val .inrange. Set )
84 call disp%skip()
85 end block
86
87 call disp%skip()
88 call disp%show("!%%%%%%%%%%%%%%%%%%%%")
89 call disp%show("!Check integer array.")
90 call disp%show("!%%%%%%%%%%%%%%%%%%%%")
91 call disp%skip()
92
93 block
94 integer(IKG), allocatable :: val, Set(:)
95 call disp%skip()
96 call disp%show("val = 1_IKG")
97 val = 1_IKG
98 call disp%show("Set = [integer(IKG) :: 1, 3]")
99 Set = [integer(IKG) :: 1, 3]
100 call disp%show("val .inrange. Set")
101 call disp%show( val .inrange. Set )
102 call disp%skip()
103 end block
104
105 block
106 integer(IKG), allocatable :: val(:), Set(:)
107 call disp%skip()
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]
112 call disp%show("val .inrange. Set")
113 call disp%show( val .inrange. Set )
114 call disp%skip()
115 end block
116
117 call disp%skip()
118 call disp%show("!%%%%%%%%%%%%%%%%%%%%")
119 call disp%show("!Check logical array.")
120 call disp%show("!%%%%%%%%%%%%%%%%%%%%")
121 call disp%skip()
122
123 block
124 logical(LKG), allocatable :: val, Set(:)
125 call disp%skip()
126 call disp%show("val = .false.")
127 val = .false.
128 call disp%show("Set = [.false., .true.]")
129 Set = [.false., .true.]
130 call disp%show("val .inrange. Set")
131 call disp%show( val .inrange. Set )
132 call disp%skip()
133 end block
134
135 block
136 logical(LKG), allocatable :: val(:), Set(:)
137 call disp%skip()
138 call disp%show("val = [.false., .true., .false.]")
139 val = [.false., .true., .false.]
140 call disp%show("Set = [.true., .true.]")
141 Set = [.true., .true.]
142 call disp%show("val .inrange. Set")
143 call disp%show( val .inrange. Set )
144 call disp%skip()
145 end block
146
147 call disp%skip()
148 call disp%show("!%%%%%%%%%%%%%%%%%%%%")
149 call disp%show("!Check complex array.")
150 call disp%show("!%%%%%%%%%%%%%%%%%%%%")
151 call disp%skip()
152
153 block
154 integer(IKG), allocatable :: val, Set(:)
155 call disp%skip()
156 call disp%show("val = (1., -1.)")
157 val = (1., -1.)
158 call disp%show("Set = [complex(CKG) :: (1., 0.), (1., -1.)]")
159 Set = [complex(CKG) :: (1., 0.), (1., -1.)]
160 call disp%show("val .inrange. Set")
161 call disp%show( val .inrange. Set )
162 call disp%skip()
163 end block
164
165 block
166 integer(IKG), allocatable :: val(:), Set(:)
167 call disp%skip()
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.)]
172 call disp%show("val .inrange. Set")
173 call disp%show( val .inrange. Set )
174 call disp%skip()
175 end block
176
177 call disp%skip()
178 call disp%show("!%%%%%%%%%%%%%%%%%")
179 call disp%show("!Check real array.")
180 call disp%show("!%%%%%%%%%%%%%%%%%")
181 call disp%skip()
182
183 block
184 real(RKG), allocatable :: val, Set(:)
185 call disp%skip()
186 call disp%show("val = 1._RKG")
187 val = 1._RKG
188 call disp%show("Set = [real(RKG) :: 1, 3]")
189 Set = [real(RKG) :: 1, 3]
190 call disp%show("val .inrange. Set")
191 call disp%show( val .inrange. Set )
192 call disp%skip()
193 end block
194
195 block
196 real(RKG), allocatable :: val(:), Set(:)
197 call disp%skip()
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]
202 call disp%show("val .inrange. Set")
203 call disp%show( val .inrange. Set )
204 call disp%skip()
205 end block
206
207end program example
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
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
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2!%%%%%%%%%%%%%%%%%%%%%%%
3!Check character scalar.
4!%%%%%%%%%%%%%%%%%%%%%%%
5
6
7val
8"M"
9Set
10"AZ"
11val .inrange. Set
12T
13
14
15val
16"ParaMonte."
17Set
18"Az"
19val .inrange. Set
20T, T, T, T, T, T, T, T, T, F
21
22
23!%%%%%%%%%%%%%%%%%%%%%%
24!Check character array.
25!%%%%%%%%%%%%%%%%%%%%%%
26
27
28val
29"paramonte"
30Set
31"aa", "zz"
32val .inrange. Set
33T
34
35
36val
37"paramonte", "ParaMonte", "Carlo ", "carlo "
38Set
39"aa ", "zz "
40val .inrange. Set
41T, F, F, T
42
43
44!%%%%%%%%%%%%%%%%%%%%
45!Check integer array.
46!%%%%%%%%%%%%%%%%%%%%
47
48
49val = 1_IKG
50Set = [integer(IKG) :: 1, 3]
51val .inrange. Set
52T
53
54
55val = [integer(IKG) :: -1, 3, 5]
56Set = [integer(IKG) :: 1, 3]
57val .inrange. Set
58F, T, F
59
60
61!%%%%%%%%%%%%%%%%%%%%
62!Check logical array.
63!%%%%%%%%%%%%%%%%%%%%
64
65
66val = .false.
67Set = [.false., .true.]
68val .inrange. Set
69T
70
71
72val = [.false., .true., .false.]
73Set = [.true., .true.]
74val .inrange. Set
75F, T, F
76
77
78!%%%%%%%%%%%%%%%%%%%%
79!Check complex array.
80!%%%%%%%%%%%%%%%%%%%%
81
82
83val = (1., -1.)
84Set = [complex(CKG) :: (1., 0.), (1., -1.)]
85val .inrange. Set
86T
87
88
89val = [(1., -1.), (0., -1.), (2., -1.)]
90Set = [complex(CKG) :: (1., 0.), (1., -1.)]
91val .inrange. Set
92T, F, F
93
94
95!%%%%%%%%%%%%%%%%%
96!Check real array.
97!%%%%%%%%%%%%%%%%%
98
99
100val = 1._RKG
101Set = [real(RKG) :: 1, 3]
102val .inrange. Set
103T
104
105
106val = [real(RKG) :: -1, 1, 5]
107Set = [real(RKG) :: 1, 3]
108val .inrange. Set
109F, T, F
110
111
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.

  1. 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.
  2. 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.

Author:
Fatemeh Bagheri, Wednesday 1:35 PM, August 11, 2021, Dallas, TX

Definition at line 924 of file pm_arrayMembership.F90.


The documentation for this interface was generated from the following file: