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

Generate and return .true. if any elements of the input array-like object val are within a range specified by the input vector Set(1:2), otherwise, return .false.. More...

Detailed Description

Generate and return .true. if any elements of the input array-like object val are within a range specified by the input vector Set(1:2), otherwise, return .false..

The functionality of this interface is equivalent to testing whether the output of set-theoretic intersection operation \(\ms{val}\subset\ms{Set}\) is non-empty.

Parameters
[in]val: The input scalar of
  • type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) or arbitrary length type parameter,
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 elements memberships 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
anyMember : 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 any elements of the input val are within the input range specified by Set.


Possible calling interfaces

use pm_arrayMembership, only: operator(.anyinrange.)
anyMember = val .anyinrange. Set(1:2) ! scalar character.
anyMember = val(:) .anyinrange. 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(.anyinrange.)
11
12 implicit none
13
14 type(display_type) :: disp
15 logical(LK), allocatable :: Member(:)
16 disp = display_type(file = "main.out.F90")
17
18 call disp%skip()
19 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%")
20 call disp%show("!Check character scalar.")
21 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%")
22 call disp%skip()
23
24 block
25 character(:,SKG), allocatable :: val, Set
26 Set = "AZ"
27 val = "M"
28 call disp%skip()
29 call disp%show("val")
30 call disp%show( val, deliml = SKG_"""" )
31 call disp%show("Set")
32 call disp%show( Set, deliml = SKG_"""" )
33 call disp%show("val .anyinrange. Set")
34 call disp%show( val .anyinrange. Set )
35 call disp%skip()
36 end block
37
38 block
39 character(:,SKG), allocatable :: val, Set
40 Set = "Az"
41 val = "ParaMonte."
42 call disp%skip()
43 call disp%show("val")
44 call disp%show( val, deliml = SKG_"""" )
45 call disp%show("Set")
46 call disp%show( Set, deliml = SKG_"""" )
47 call disp%show("val .anyinrange. Set")
48 call disp%show( val .anyinrange. Set )
49 call disp%skip()
50 end block
51
52 call disp%skip()
53 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
54 call disp%show("!Check character array.")
55 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
56 call disp%skip()
57
58 block
59 character(:,SKG), allocatable :: val(:)
60 character(2,SKG), allocatable :: Set(:)
61 Set = [character(2,SKG) :: "aa", "zz"]
62 val = ["paramonte"]
63 call disp%skip()
64 call disp%show("val")
65 call disp%show( val, deliml = SKG_"""" )
66 call disp%show("Set")
67 call disp%show( Set, deliml = SKG_"""" )
68 call disp%show("val .anyinrange. Set")
69 call disp%show( val .anyinrange. Set )
70 call disp%skip()
71 end block
72
73 block
74 character( 9,SKG), allocatable :: val(:)
75 character(10,SKG), allocatable :: Set(:)
76 Set = [character(10,SKG) :: "aa", "zz"]
77 val = [character( 9,SKG) :: "paramonte", "ParaMonte", "Carlo", "carlo"]
78 call disp%skip()
79 call disp%show("val")
80 call disp%show( val, deliml = SKG_"""" )
81 call disp%show("Set")
82 call disp%show( Set, deliml = SKG_"""" )
83 call disp%show("val .anyinrange. Set")
84 call disp%show( val .anyinrange. Set )
85 call disp%skip()
86 end block
87
88 call disp%skip()
89 call disp%show("!%%%%%%%%%%%%%%%%%%%%")
90 call disp%show("!Check integer array.")
91 call disp%show("!%%%%%%%%%%%%%%%%%%%%")
92 call disp%skip()
93
94 block
95 integer(IKG), allocatable :: val(:), Set(:)
96 call disp%skip()
97 call disp%show("val = [1_IKG]")
98 val = [1_IKG]
99 call disp%show("Set = [integer(IKG) :: 1, 3]")
100 Set = [integer(IKG) :: 1, 3]
101 call disp%show("val .anyinrange. Set")
102 call disp%show( val .anyinrange. Set )
103 call disp%skip()
104 end block
105
106 block
107 integer(IKG), allocatable :: val(:), Set(:)
108 call disp%skip()
109 call disp%show("val = [integer(IKG) :: -1, 3, 5]")
110 val = [integer(IKG) :: -1, 3, 5]
111 call disp%show("Set = [integer(IKG) :: 1, 3]")
112 Set = [integer(IKG) :: 1, 3]
113 call disp%show("val .anyinrange. Set")
114 call disp%show( val .anyinrange. Set )
115 call disp%skip()
116 end block
117
118 call disp%skip()
119 call disp%show("!%%%%%%%%%%%%%%%%%%%%")
120 call disp%show("!Check logical array.")
121 call disp%show("!%%%%%%%%%%%%%%%%%%%%")
122 call disp%skip()
123
124 block
125 logical(LKG), allocatable :: val(:), Set(:)
126 call disp%skip()
127 call disp%show("val = [.false.]")
128 val = [.false.]
129 call disp%show("Set = [.false., .true.]")
130 Set = [.false., .true.]
131 call disp%show("val .anyinrange. Set")
132 call disp%show( val .anyinrange. Set )
133 call disp%skip()
134 end block
135
136 block
137 logical(LKG), allocatable :: val(:), Set(:)
138 call disp%skip()
139 call disp%show("val = [.false., .true., .false.]")
140 val = [.false., .true., .false.]
141 call disp%show("Set = [.true., .true.]")
142 Set = [.true., .true.]
143 call disp%show("val .anyinrange. Set")
144 call disp%show( val .anyinrange. Set )
145 call disp%skip()
146 end block
147
148 call disp%skip()
149 call disp%show("!%%%%%%%%%%%%%%%%%%%%")
150 call disp%show("!Check complex array.")
151 call disp%show("!%%%%%%%%%%%%%%%%%%%%")
152 call disp%skip()
153
154 block
155 integer(IKG), allocatable :: val(:), Set(:)
156 call disp%skip()
157 call disp%show("val = [(1., -1.)]")
158 val = [(1., -1.)]
159 call disp%show("Set = [complex(CKG) :: (1., 0.), (1., -1.)]")
160 Set = [complex(CKG) :: (1., 0.), (1., -1.)]
161 call disp%show("val .anyinrange. Set")
162 call disp%show( val .anyinrange. Set )
163 call disp%skip()
164 end block
165
166 block
167 integer(IKG), allocatable :: val(:), Set(:)
168 call disp%skip()
169 call disp%show("val = [(1., -1.), (0., -1.), (2., -1.)]")
170 val = [(1., -1.), (0., -1.), (2., -1.)]
171 call disp%show("Set = [complex(CKG) :: (1., 0.), (1., -1.)]")
172 Set = [complex(CKG) :: (1., 0.), (1., -1.)]
173 call disp%show("val .anyinrange. Set")
174 call disp%show( val .anyinrange. Set )
175 call disp%skip()
176 end block
177
178 call disp%skip()
179 call disp%show("!%%%%%%%%%%%%%%%%%")
180 call disp%show("!Check real array.")
181 call disp%show("!%%%%%%%%%%%%%%%%%")
182 call disp%skip()
183
184 block
185 real(RKG), allocatable :: val(:), Set(:)
186 call disp%skip()
187 call disp%show("val = [1._RKG]")
188 val = [1._RKG]
189 call disp%show("Set = [real(RKG) :: 1, 3]")
190 Set = [real(RKG) :: 1, 3]
191 call disp%show("val .anyinrange. Set")
192 call disp%show( val .anyinrange. Set )
193 call disp%skip()
194 end block
195
196 block
197 real(RKG), allocatable :: val(:), Set(:)
198 call disp%skip()
199 call disp%show("val = [real(RKG) :: -1, 1, 5]")
200 val = [real(RKG) :: -1, 1, 5]
201 call disp%show("Set = [real(RKG) :: 1, 3]")
202 Set = [real(RKG) :: 1, 3]
203 call disp%show("val .anyinrange. Set")
204 call disp%show( val .anyinrange. Set )
205 call disp%skip()
206 end block
207
208end 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 .anyinrange. Set
12T
13
14
15val
16"ParaMonte."
17Set
18"Az"
19val .anyinrange. Set
20T
21
22
23!%%%%%%%%%%%%%%%%%%%%%%
24!Check character array.
25!%%%%%%%%%%%%%%%%%%%%%%
26
27
28val
29"paramonte"
30Set
31"aa", "zz"
32val .anyinrange. Set
33T
34
35
36val
37"paramonte", "ParaMonte", "Carlo ", "carlo "
38Set
39"aa ", "zz "
40val .anyinrange. Set
41T
42
43
44!%%%%%%%%%%%%%%%%%%%%
45!Check integer array.
46!%%%%%%%%%%%%%%%%%%%%
47
48
49val = [1_IKG]
50Set = [integer(IKG) :: 1, 3]
51val .anyinrange. Set
52T
53
54
55val = [integer(IKG) :: -1, 3, 5]
56Set = [integer(IKG) :: 1, 3]
57val .anyinrange. Set
58T
59
60
61!%%%%%%%%%%%%%%%%%%%%
62!Check logical array.
63!%%%%%%%%%%%%%%%%%%%%
64
65
66val = [.false.]
67Set = [.false., .true.]
68val .anyinrange. Set
69T
70
71
72val = [.false., .true., .false.]
73Set = [.true., .true.]
74val .anyinrange. Set
75T
76
77
78!%%%%%%%%%%%%%%%%%%%%
79!Check complex array.
80!%%%%%%%%%%%%%%%%%%%%
81
82
83val = [(1., -1.)]
84Set = [complex(CKG) :: (1., 0.), (1., -1.)]
85val .anyinrange. Set
86T
87
88
89val = [(1., -1.), (0., -1.), (2., -1.)]
90Set = [complex(CKG) :: (1., 0.), (1., -1.)]
91val .anyinrange. Set
92T
93
94
95!%%%%%%%%%%%%%%%%%
96!Check real array.
97!%%%%%%%%%%%%%%%%%
98
99
100val = [1._RKG]
101Set = [real(RKG) :: 1, 3]
102val .anyinrange. Set
103T
104
105
106val = [real(RKG) :: -1, 1, 5]
107Set = [real(RKG) :: 1, 3]
108val .anyinrange. Set
109T
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 3106 of file pm_arrayMembership.F90.


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