ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_arrayRemove::setRemoved Interface Reference

Return the remaining parts of the input array as a sequence after removing the input pattern at the requested occurrences. More...

Detailed Description

Return the remaining parts of the input array as a sequence after removing the input pattern at the requested occurrences.

If an input vector of instance is specified, containing the indices of the specific instances of pattern that must be removed, then only those instances will be removed from the array.

Parameters
[in,out]array: The input/output allocatable array of rank 1 of either
  • type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU), 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,
  • a scalar allocatable character of default kind SK.
within which the requested instances of pattern is to be removed.
On output, array is reallocated to contain the input array with the requested instances of pattern removed from it.
[in]pattern: The input contiguous array of rank 1 or scalar of the same type and kind as the input array containing the pattern that must be removed from the input array.
iseq: The external user-specified function that takes two input explicit-shape arguments of the same type and kind as the input array and possibly, also the length of the arguments as the third argument.
It returns a scalar logical of default kind LK that is .true. if all elements of the two input arguments are equivalent (e.g., equal) according to the user-defined criterion, otherwise, it is .false..
If pattern is an array of rank 1, then the last argument to iseq is the length of the input pattern, preceded by a segment of array and pattern as the first and second arguments whose lengths are given by the third argument lenPattern.
The following illustrates the generic interface of iseq where pattern is array-valued,
function iseq(Segment, pattern, lenPattern) result(equivalent)
use pm_kind, only: IK, LK
integer(IK) , intent(in) :: lenPattern
TYPE(KIND) , intent(in) :: Segment(lenPattern), pattern(lenPattern)
logical(LK) :: equivalent
end function
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
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
where TYPE(KIND) represents the type and kind of the input argument array, which can be one of the following,
use pm_kind, only: SK, IK, LK, CK, RK
character(*, SK), intent(in) :: Segment(lenPattern), pattern(lenPattern)
integer(IK) , intent(in) :: Segment(lenPattern), pattern(lenPattern)
logical(LK) , intent(in) :: Segment(lenPattern), pattern(lenPattern)
complex(CK) , intent(in) :: Segment(lenPattern), pattern(lenPattern)
real(RK) , intent(in) :: Segment(lenPattern), pattern(lenPattern)
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 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 SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
where the kinds SK, IK, LK, CK, RK, can refer to any kind type parameter that is supported by the processor.
The following illustrates the generic interface of iseq where pattern is scalar-valued (including Fortran scalar strings),
function iseq(segment, pattern) result(equivalent)
use pm_kind, only: LK
TYPE(KIND) , intent(in) :: segment, pattern
logical(LK) :: equivalent
end function
where TYPE(KIND) represents the type and kind of the input argument array, which can be one of the following,
use pm_kind, only: SK, IK, LK, CK, RK
character(*, SK), intent(in) :: segment, pattern
integer(IK) , intent(in) :: segment, pattern
logical(LK) , intent(in) :: segment, pattern
complex(CK) , intent(in) :: segment, pattern
real(RK) , intent(in) :: segment, pattern
where the kinds SK, IK, LK, CK, RK, can refer to any kind type parameter that is supported by the processor.
This user-defined equivalence check is extremely useful where a user-defined equivalence test other than exact equality or identity is needed, for example, when the array segments should match the input pattern only within a given threshold or, when the case-sensitivity in character comparisons do not matter.
In such cases, user can define a custom equivalence criterion within the user-defined external function iseq to achieve the goal.
(optional, the default equivalence operator is .eqv. if the input array is logical, otherwise ==)
[in]instance: The input contiguous array of rank 1 of type integer of default kind IK, containing the instances of the input pattern in the input array that should be removed.
Any element of instance that points to an out-of-scope instance of pattern in the input array will be ignored.
Any element of instance that is negatively valued will be counted from end of the input array.
For example, instance = [2,-1] requests removing the second instance of pattern in array from the beginning and removing the first instance of pattern starting from the end of array.
(optional, the default value corresponds to removing all instances of pattern in array)
[in]sorted: The input logical of default kind LK indicating whether the elements of the specified input instance are all in ascending-order.
This includes the negative elements of instance after they are translated to the corresponding positive instances from the beginning of the input array.
Setting sorted = .true. will lead to faster runtime of the procedure.
However, the onus will be strictly on the user to ensure all elements of instance are in ascending-order.
This is generally not an easy guarantee to make if there are negative elements in instance.
Therefore, set sorted = .true. only if you can guarantee the validity of the condition.
(optional, default = .false.. It can be present as input argument only if the input argument instance is present.)
[in]unique: The input logical of default kind LK indicating whether the elements of the specified input instance are all unique.
This includes the negative elements of instance after they are translated to the corresponding positive instances from the beginning of the input array.
Setting unique = .true. will lead to faster runtime of the procedure.
However, the onus will be strictly on the user to ensure all elements of instance are unique.
This is generally not an easy guarantee to make if there are negative elements in instance.
Therefore, set unique = .true. only if you can guarantee the validity of the condition.
(optional, default = .false.. It can be present as input argument only if the input argument instance is present.)


Possible calling interfaces

call setRemoved(array, pattern)
call setRemoved(array, pattern, iseq)
call setRemoved(array, pattern, instance, sorted = sorted, unique = unique)
call setRemoved(array, pattern, iseq, instance, sorted = sorted, unique = unique)
Return the remaining parts of the input array as a sequence after removing the input pattern at the r...
This module contains procedures and generic interfaces for removing a pattern from arrays of various ...
Warning
The pure procedure(s) documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1.
By default, these procedures are pure in release build and impure in debug and testing builds.
The procedures under this generic interface are impure when the user-specified external procedure iseq is specified as input argument.
Note that in Fortran, trailing blanks are ignored in character comparison, that is, "Fortran" == "Fortran " yields .true..
Remarks
The functions under this generic interface are slightly slower than the setRemoved subroutine implementations.
See pm_arrayRemove for the relevant benchmarks.
Note
Upon return, the output allocatable array is guaranteed to have the same lower bound as before, but its upper bound will likely be different.
See also
getRemoved
getReplaced
setReplaced
setInserted
setSplit


Example usage

1program example
2
3 use pm_kind, only: LK
4 use pm_kind, only: SK ! All kinds are supported.
5 use pm_kind, only: IK ! All kinds are supported.
6 use pm_kind, only: CK ! All kinds are supported.
7 use pm_kind, only: RK ! All kinds are supported.
8 use pm_io, only: display_type
10
11 implicit none
12
13 integer(IK) , allocatable :: instance(:) ! Must be of default kind IK
14
15 character(:, SK), allocatable :: stringRef_SK , string_SK , stringPattern_SK
16 character(9, SK), allocatable :: ArrayRef_SK(:) , Array_SK(:) , ArrayPattern_SK(:) ! Can be any processor-supported kind.
17 integer(IK) , allocatable :: ArrayRef_IK(:) , Array_IK(:) , ArrayPattern_IK(:) ! Can be any processor-supported kind.
18 complex(CK) , allocatable :: ArrayRef_CK(:) , Array_CK(:) , ArrayPattern_CK(:) ! Can be any processor-supported kind.
19 real(RK) , allocatable :: ArrayRef_RK(:) , Array_RK(:) , ArrayPattern_RK(:) ! Can be any processor-supported kind.
20 logical(LK) , allocatable :: ArrayRef_LK(:) , Array_LK(:) , ArrayPattern_LK(:)
21
22 type(display_type) :: disp
23
24 disp = display_type(file = "main.out.F90")
25
26 stringRef_SK = "ParaMonte is a Machine Learning Library "
27 ArrayRef_SK = ["ParaMonte", "XXXXXXXXX", "is ", "XXXXXXXXX", "a ", "XXXXXXXXX", "Monte ", "XXXXXXXXX", "Carlo ", "XXXXXXXXX", "Library. ", "XXXXXXXXX"]
28 ArrayRef_IK = [1_IK, 0_IK, 2_IK, 0_IK, 3_IK, 0_IK, 4_IK]
29 ArrayRef_RK = [1._RK, 0._RK, 2._RK, 0._RK, 3._RK, 0._RK, 4._RK]
30 ArrayRef_CK = [(1._CK, -1._CK), (0._CK, -0._CK), (2._CK, -2._CK), (0._CK, -0._CK), (3._CK, -3._CK), (0._CK, -0._CK), (4._CK, -4._CK)]
31 ArrayRef_LK = [.false._LK, .true._LK, .false._LK, .true._LK, .false._LK, .true._LK, .false._LK]
32
33 call disp%skip()
34 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
35 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
36 call disp%show("! Remove all instances of pattern in array.")
37 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
38 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
39 call disp%skip()
40
41 string_SK = stringRef_SK
42 Array_SK = ArrayRef_SK
43 Array_IK = ArrayRef_IK
44 Array_RK = ArrayRef_RK
45 Array_CK = ArrayRef_CK
46 Array_LK = ArrayRef_LK
47
48 stringPattern_SK = " "
49 ArrayPattern_SK = ["XXXXXXXXX"]
50 ArrayPattern_IK = [0_IK]
51 ArrayPattern_RK = [0._RK]
52 ArrayPattern_CK = [(0._CK, -0._CK)]
53 ArrayPattern_LK = [.true._LK]
54
55 call disp%skip()
56 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
57 call disp%show("! Remove character scalar.")
58 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
59 call disp%skip()
60
61 call disp%show("string_SK")
62 call disp%show( string_SK, deliml = SK_"""" )
63 call disp%show("stringPattern_SK")
64 call disp%show( stringPattern_SK, deliml = SK_"""" )
65 call disp%show("call setRemoved(string_SK, stringPattern_SK)")
66 call setRemoved(string_SK, stringPattern_SK)
67 call disp%show("string_SK")
68 call disp%show( string_SK, deliml = SK_"""" )
69
70 call disp%skip()
71 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%")
72 call disp%show("! Remove character array.")
73 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%")
74 call disp%skip()
75
76 call disp%show("Array_SK")
77 call disp%show( Array_SK, deliml = SK_"""" )
78 call disp%show("ArrayPattern_SK")
79 call disp%show( ArrayPattern_SK, deliml = SK_"""" )
80 call disp%show("call setRemoved(Array_SK, ArrayPattern_SK)")
81 call setRemoved(Array_SK, ArrayPattern_SK)
82 call disp%show("Array_SK")
83 call disp%show( Array_SK, deliml = SK_"""" )
84
85 call disp%skip()
86 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
87 call disp%show("! Remove logical array.")
88 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
89 call disp%skip()
90
91 call disp%show("Array_LK")
92 call disp%show( Array_LK )
93 call disp%show("ArrayPattern_LK")
94 call disp%show( ArrayPattern_LK )
95 call disp%show("call setRemoved(Array_LK, ArrayPattern_LK)")
96 call setRemoved(Array_LK, ArrayPattern_LK)
97 call disp%show("Array_LK")
98 call disp%show( Array_LK )
99
100 call disp%skip()
101 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
102 call disp%show("! Remove integer array.")
103 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
104 call disp%skip()
105
106 call disp%show("Array_IK")
107 call disp%show( Array_IK )
108 call disp%show("ArrayPattern_IK")
109 call disp%show( ArrayPattern_IK )
110 call disp%show("call setRemoved(Array_IK, ArrayPattern_IK)")
111 call setRemoved(Array_IK, ArrayPattern_IK)
112 call disp%show("Array_IK")
113 call disp%show( Array_IK )
114
115 call disp%skip()
116 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
117 call disp%show("! Remove complex array.")
118 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
119 call disp%skip()
120
121 call disp%show("Array_CK")
122 call disp%show( Array_CK )
123 call disp%show("ArrayPattern_CK")
124 call disp%show( ArrayPattern_CK )
125 call disp%show("call setRemoved(Array_CK, ArrayPattern_CK)")
126 call setRemoved(Array_CK, ArrayPattern_CK)
127 call disp%show("Array_CK")
128 call disp%show( Array_CK )
129
130 call disp%skip()
131 call disp%show("!%%%%%%%%%%%%%%%%%%%")
132 call disp%show("! Remove real array.")
133 call disp%show("!%%%%%%%%%%%%%%%%%%%")
134 call disp%skip()
135
136 call disp%show("Array_RK")
137 call disp%show( Array_RK )
138 call disp%show("ArrayPattern_RK")
139 call disp%show( ArrayPattern_RK )
140 call disp%show("call setRemoved(Array_RK, ArrayPattern_RK)")
141 call setRemoved(Array_RK, ArrayPattern_RK)
142 call disp%show("Array_RK")
143 call disp%show( Array_RK )
144
145
146 call disp%skip()
147 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
148 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
149 call disp%show("! Remove only particular instances of pattern in array.")
150 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
151 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
152 call disp%skip()
153
154 stringRef_SK = "A_A_A_A_A_A_A_A_A"
155 ArrayRef_SK = ["A", "_", "A", "_", "A", "_", "A", "_", "A", "_", "A", "_", "A", "_", "A", "_", "A"]
156 ArrayRef_IK = [0_IK, 1_IK, 0_IK, 2_IK, 3_IK, 0_IK, 4_IK, 5_IK, 0_IK, 0_IK]
157 ArrayRef_RK = [0._RK, 1._RK, 0._RK, 2._RK, 3._RK, 0._RK, 4._RK, 5._RK, 0._RK, 0._RK]
158 ArrayRef_CK = [(0._CK, -0._CK), (1._CK, -1._CK), (0._CK, -0._CK), (2._CK, -2._CK), (3._CK, -3._CK), (0._CK, -0._CK), (4._CK, -4._CK), (5._CK, -5._CK), (0._CK, -0._CK), (0._CK, -0._CK)]
159 ArrayRef_LK = [.false._LK, .true._LK, .false._LK, .true._LK, .true._LK, .false._LK, .true._LK, .true._LK, .false._LK, .false._LK]
160
161 stringPattern_SK = "_"
162 ArrayPattern_SK = ["_"]
163 ArrayPattern_IK = [0_IK]
164 ArrayPattern_RK = [0._RK]
165 ArrayPattern_CK = [(0._CK, -0._CK)]
166 ArrayPattern_LK = [.false._LK]
167
168 instance = [-3, 2, -4] ! remove at the second occurrence from the beginning and the third occurrence from the end. Duplicate indices are ignored.
169
170 call disp%skip()
171 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
172 call disp%show("! Remove character scalar.")
173 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
174 call disp%skip()
175
176 string_SK = stringRef_SK
177 call disp%show("string_SK")
178 call disp%show( string_SK, deliml = SK_"""" )
179 call disp%show("stringPattern_SK")
180 call disp%show( stringPattern_SK, deliml = SK_"""" )
181 call disp%show("instance")
182 call disp%show( instance )
183 call disp%show("call setRemoved(string_SK, stringPattern_SK, instance = instance)")
184 call setRemoved(string_SK, stringPattern_SK, instance = instance)
185 call disp%show("string_SK")
186 call disp%show( string_SK, deliml = SK_"""" )
187
188 call disp%skip()
189 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
190 call disp%show("! Remove vector `pattern` from character array.")
191 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
192 call disp%skip()
193
194 Array_SK = ArrayRef_SK
195 call disp%show("Array_SK")
196 call disp%show( Array_SK, deliml = SK_"""" )
197 call disp%show("ArrayPattern_SK")
198 call disp%show( ArrayPattern_SK, deliml = SK_"""" )
199 call disp%show("instance")
200 call disp%show( instance )
201 call disp%show("call setRemoved(Array_SK, ArrayPattern_SK, instance = instance)")
202 call setRemoved(Array_SK, ArrayPattern_SK, instance = instance)
203 call disp%show("Array_SK")
204 call disp%show( Array_SK, deliml = SK_"""" )
205
206 call disp%skip()
207 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
208 call disp%show("! Remove character array with scalar `pattern`.")
209 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
210 call disp%skip()
211
212 Array_SK = ArrayRef_SK
213 call disp%show("Array_SK")
214 call disp%show( Array_SK, deliml = SK_"""" )
215 call disp%show("ArrayPattern_SK(1)")
216 call disp%show( ArrayPattern_SK(1), deliml = SK_"""" )
217 call disp%show("instance")
218 call disp%show( instance )
219 call disp%show("call setRemoved(Array_SK, ArrayPattern_SK(1), instance = instance)")
220 call setRemoved(Array_SK, ArrayPattern_SK(1), instance = instance)
221 call disp%show("Array_SK")
222 call disp%show( Array_SK, deliml = SK_"""" )
223
224 call disp%skip()
225 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
226 call disp%show("! Remove logical array with vector `pattern`.")
227 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
228 call disp%skip()
229
230 Array_LK = ArrayRef_LK
231 call disp%show("Array_LK")
232 call disp%show( Array_LK )
233 call disp%show("ArrayPattern_LK")
234 call disp%show( ArrayPattern_LK )
235 call disp%show("instance")
236 call disp%show( instance )
237 call disp%show("call setRemoved(Array_LK, ArrayPattern_LK, instance = instance)")
238 call setRemoved(Array_LK, ArrayPattern_LK, instance = instance)
239 call disp%show("Array_LK")
240 call disp%show( Array_LK )
241
242 call disp%skip()
243 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
244 call disp%show("! Remove logical array with scalar `pattern`.")
245 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
246 call disp%skip()
247
248 Array_LK = ArrayRef_LK
249 call disp%show("Array_LK")
250 call disp%show( Array_LK )
251 call disp%show("ArrayPattern_LK(1)")
252 call disp%show( ArrayPattern_LK(1) )
253 call disp%show("instance")
254 call disp%show( instance )
255 call disp%show("call setRemoved(Array_LK, ArrayPattern_LK(1), instance = instance)")
256 call setRemoved(Array_LK, ArrayPattern_LK(1), instance = instance)
257 call disp%show("Array_LK")
258 call disp%show( Array_LK )
259
260 call disp%skip()
261 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
262 call disp%show("! Remove integer array with vector `pattern`.")
263 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
264 call disp%skip()
265
266 Array_IK = ArrayRef_IK
267 call disp%show("Array_IK")
268 call disp%show( Array_IK )
269 call disp%show("ArrayPattern_IK")
270 call disp%show( ArrayPattern_IK )
271 call disp%show("instance")
272 call disp%show( instance )
273 call disp%show("call setRemoved(Array_IK, ArrayPattern_IK, instance = instance)")
274 call setRemoved(Array_IK, ArrayPattern_IK, instance = instance)
275 call disp%show("Array_IK")
276 call disp%show( Array_IK )
277
278 call disp%skip()
279 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
280 call disp%show("! Remove integer array with scalar `pattern`.")
281 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
282 call disp%skip()
283
284 Array_IK = ArrayRef_IK
285 call disp%show("Array_IK")
286 call disp%show( Array_IK )
287 call disp%show("ArrayPattern_IK(1)")
288 call disp%show( ArrayPattern_IK(1) )
289 call disp%show("instance")
290 call disp%show( instance )
291 call disp%show("call setRemoved(Array_IK, ArrayPattern_IK(1), instance = instance)")
292 call setRemoved(Array_IK, ArrayPattern_IK(1), instance = instance)
293 call disp%show("Array_IK")
294 call disp%show( Array_IK )
295
296 call disp%skip()
297 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
298 call disp%show("! Remove complex array with vector `pattern`.")
299 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
300 call disp%skip()
301
302 Array_CK = ArrayRef_CK
303 call disp%show("Array_CK")
304 call disp%show( Array_CK )
305 call disp%show("ArrayPattern_CK")
306 call disp%show( ArrayPattern_CK )
307 call disp%show("instance")
308 call disp%show( instance )
309 call disp%show("call setRemoved(Array_CK, ArrayPattern_CK, instance = instance)")
310 call setRemoved(Array_CK, ArrayPattern_CK, instance = instance)
311 call disp%show("Array_CK")
312 call disp%show( Array_CK )
313
314 call disp%skip()
315 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
316 call disp%show("! Remove complex array with scalar `pattern`.")
317 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
318 call disp%skip()
319
320 Array_CK = ArrayRef_CK
321 call disp%show("Array_CK")
322 call disp%show( Array_CK )
323 call disp%show("ArrayPattern_CK(1)")
324 call disp%show( ArrayPattern_CK(1) )
325 call disp%show("instance")
326 call disp%show( instance )
327 call disp%show("call setRemoved(Array_CK, ArrayPattern_CK(1), instance = instance)")
328 call setRemoved(Array_CK, ArrayPattern_CK(1), instance = instance)
329 call disp%show("Array_CK")
330 call disp%show( Array_CK )
331
332 call disp%skip()
333 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
334 call disp%show("! Remove real array with vector `pattern`.")
335 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
336 call disp%skip()
337
338 Array_RK = ArrayRef_RK
339 call disp%show("Array_RK")
340 call disp%show( Array_RK )
341 call disp%show("ArrayPattern_RK")
342 call disp%show( ArrayPattern_RK )
343 call disp%show("instance")
344 call disp%show( instance )
345 call disp%show("call setRemoved(Array_RK, ArrayPattern_RK, instance = instance)")
346 call setRemoved(Array_RK, ArrayPattern_RK, instance = instance)
347 call disp%show("Array_RK")
348 call disp%show( Array_RK )
349
350 call disp%skip()
351 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
352 call disp%show("! Remove real array with scalar `pattern`.")
353 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
354 call disp%skip()
355
356 Array_RK = ArrayRef_RK
357 call disp%show("Array_RK")
358 call disp%show( Array_RK )
359 call disp%show("ArrayPattern_RK(1)")
360 call disp%show( ArrayPattern_RK(1) )
361 call disp%show("instance")
362 call disp%show( instance )
363 call disp%show("call setRemoved(Array_RK, ArrayPattern_RK(1), instance = instance)")
364 call setRemoved(Array_RK, ArrayPattern_RK(1), instance = instance)
365 call disp%show("Array_RK")
366 call disp%show( Array_RK )
367
368
369 call disp%skip()
370 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
371 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
372 call disp%show("! Remove specific instances with a user-defined equivalence test.")
373 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
374 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
375 call disp%skip()
376
377
378 call disp%skip()
379 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
380 call disp%show("! Remove case-insensitive instances of vector `pattern` within the character array.")
381 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
382 call disp%skip()
383
384 string_SK = "ABBAbbA"
385 stringPattern_SK = "bb"
386
387 call disp%show("string_SK")
388 call disp%show( string_SK, deliml = SK_"""" )
389 call disp%show("stringPattern_SK")
390 call disp%show( stringPattern_SK, deliml = SK_"""" )
391 call disp%show("call setRemoved(string_SK, stringPattern_SK, iseq = iseq_SK) ! case-insensitive string removal.")
392 call setRemoved(string_SK, stringPattern_SK, iseq = iseq_SK)
393 call disp%show("string_SK")
394 call disp%show( string_SK, deliml = SK_"""" )
395
396 call disp%skip()
397 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
398 call disp%show("! Remove specific instances of vector `pattern` within the real array.")
399 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
400 call disp%skip()
401
402 ArrayRef_RK = [0._RK, 1.01_RK, 1.04_RK, 0.98_RK, 1.0_RK, 1.02_RK]
403 ArrayPattern_RK = [-1._RK, 1._RK]
404 instance = [-2_IK]
405
406 Array_RK = ArrayRef_RK
407 call disp%show("Array_RK")
408 call disp%show( Array_RK )
409 call disp%show("ArrayPattern_RK")
410 call disp%show( ArrayPattern_RK )
411 call disp%show("instance")
412 call disp%show( instance )
413 call disp%show("call setRemoved(Array_RK, ArrayPattern_RK, iseq = iseq_vec_RK, instance = instance)")
414 call setRemoved(Array_RK, ArrayPattern_RK, iseq = iseq_vec_RK, instance = instance)
415 call disp%show("Array_RK")
416 call disp%show( Array_RK )
417
418 call disp%skip()
419 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
420 call disp%show("! Remove specific instances of scalar `pattern` within the real array.")
421 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
422 call disp%skip()
423
424 Array_RK = ArrayRef_RK
425 call disp%show("Array_RK")
426 call disp%show( Array_RK )
427 call disp%show("ArrayPattern_RK(1)")
428 call disp%show( ArrayPattern_RK(1) )
429 call disp%show("instance")
430 call disp%show( instance )
431 call disp%show("call setRemoved(Array_RK, ArrayPattern_RK(1), iseq = iseq_RK, instance = instance)")
432 call setRemoved(Array_RK, ArrayPattern_RK(1), iseq = iseq_RK, instance = instance)
433 call disp%show("Array_RK")
434 call disp%show( Array_RK )
435
436 call disp%skip()
437 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
438 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
439 call disp%show("! Call to setRemoved() preserves the lower bound of the input `Array`.")
440 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
441 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
442 call disp%skip()
443
444 deallocate(Array_IK)
445 ArrayPattern_IK = [0_IK]
446 allocate(Array_IK(-7:-1), source = [1_IK, 0_IK, 2_IK, 0_IK, 3_IK, 0_IK, 4_IK])
447 call disp%show("[lbound(Array_IK,1), ubound(Array_IK,1)]")
448 call disp%show( [lbound(Array_IK,1), ubound(Array_IK,1)] )
449 call disp%show("Array_IK")
450 call disp%show( Array_IK )
451 call disp%show("ArrayPattern_IK(1)")
452 call disp%show( ArrayPattern_IK(1) )
453 call disp%show("call setRemoved(Array_IK, ArrayPattern_IK(1))")
454 call setRemoved(Array_IK, ArrayPattern_IK(1))
455 call disp%show("Array_IK")
456 call disp%show( Array_IK )
457 call disp%show("[lbound(Array_IK,1), ubound(Array_IK,1)]")
458 call disp%show( [lbound(Array_IK,1), ubound(Array_IK,1)] )
459
460contains
461
462 pure function iseq_SK(ArraySegment, pattern) result(equivalent)
463 use pm_strASCII, only: getStrLower
464 character(*, SK), intent(in) :: pattern, ArraySegment
465 logical(LK) :: equivalent
466 equivalent = pattern == getStrLower(ArraySegment)
467 end function
468
469 pure function iseq_RK(arraysegment, pattern) result(equivalent)
470 real(RK) , intent(in) :: pattern, arraySegment
471 logical(LK) :: equivalent
472 equivalent = abs(abs(pattern) - abs(arraySegment)) < 0.05_RK
473 end function
474
475 pure function iseq_vec_RK(ArraySegment, pattern, lenPattern) result(equivalent)
476 integer(IK) , intent(in) :: lenPattern
477 real(RK) , intent(in) :: pattern(lenPattern), ArraySegment(lenPattern)
478 logical(LK) :: equivalent
479 equivalent = all(abs(abs(pattern) - abs(ArraySegment)) < 0.05_RK)
480 end function
481
482end 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
Generate and return the input string where the uppercase English alphabets are all converted to lower...
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 contains the uncommon and hardly representable ASCII characters as well as procedures for...
Definition: pm_strASCII.F90:61
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!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4! Remove all instances of pattern in array.
5!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7
8
9!%%%%%%%%%%%%%%%%%%%%%%%%%
10! Remove character scalar.
11!%%%%%%%%%%%%%%%%%%%%%%%%%
12
13string_SK
14"ParaMonte is a Machine Learning Library "
15stringPattern_SK
16" "
17call setRemoved(string_SK, stringPattern_SK)
18string_SK
19"ParaMonteisaMachineLearningLibrary"
20
21!%%%%%%%%%%%%%%%%%%%%%%%%
22! Remove character array.
23!%%%%%%%%%%%%%%%%%%%%%%%%
24
25Array_SK
26"ParaMonte", "XXXXXXXXX", "is ", "XXXXXXXXX", "a ", "XXXXXXXXX", "Monte ", "XXXXXXXXX", "Carlo ", "XXXXXXXXX", "Library. ", "XXXXXXXXX"
27ArrayPattern_SK
28"XXXXXXXXX"
29call setRemoved(Array_SK, ArrayPattern_SK)
30Array_SK
31"ParaMonte", "is ", "a ", "Monte ", "Carlo ", "Library. "
32
33!%%%%%%%%%%%%%%%%%%%%%%
34! Remove logical array.
35!%%%%%%%%%%%%%%%%%%%%%%
36
37Array_LK
38F, T, F, T, F, T, F
39ArrayPattern_LK
40T
41call setRemoved(Array_LK, ArrayPattern_LK)
42Array_LK
43F, F, F, F
44
45!%%%%%%%%%%%%%%%%%%%%%%
46! Remove integer array.
47!%%%%%%%%%%%%%%%%%%%%%%
48
49Array_IK
50+1, +0, +2, +0, +3, +0, +4
51ArrayPattern_IK
52+0
53call setRemoved(Array_IK, ArrayPattern_IK)
54Array_IK
55+1, +2, +3, +4
56
57!%%%%%%%%%%%%%%%%%%%%%%
58! Remove complex array.
59!%%%%%%%%%%%%%%%%%%%%%%
60
61Array_CK
62(+1.0000000000000000, -1.0000000000000000), (+0.0000000000000000, -0.0000000000000000), (+2.0000000000000000, -2.0000000000000000), (+0.0000000000000000, -0.0000000000000000), (+3.0000000000000000, -3.0000000000000000), (+0.0000000000000000, -0.0000000000000000), (+4.0000000000000000, -4.0000000000000000)
63ArrayPattern_CK
64(+0.0000000000000000, -0.0000000000000000)
65call setRemoved(Array_CK, ArrayPattern_CK)
66Array_CK
67(+1.0000000000000000, -1.0000000000000000), (+2.0000000000000000, -2.0000000000000000), (+3.0000000000000000, -3.0000000000000000), (+4.0000000000000000, -4.0000000000000000)
68
69!%%%%%%%%%%%%%%%%%%%
70! Remove real array.
71!%%%%%%%%%%%%%%%%%%%
72
73Array_RK
74+1.0000000000000000, +0.0000000000000000, +2.0000000000000000, +0.0000000000000000, +3.0000000000000000, +0.0000000000000000, +4.0000000000000000
75ArrayPattern_RK
76+0.0000000000000000
77call setRemoved(Array_RK, ArrayPattern_RK)
78Array_RK
79+1.0000000000000000, +2.0000000000000000, +3.0000000000000000, +4.0000000000000000
80
81!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83! Remove only particular instances of pattern in array.
84!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86
87
88!%%%%%%%%%%%%%%%%%%%%%%%%%
89! Remove character scalar.
90!%%%%%%%%%%%%%%%%%%%%%%%%%
91
92string_SK
93"A_A_A_A_A_A_A_A_A"
94stringPattern_SK
95"_"
96instance
97-3, +2, -4
98call setRemoved(string_SK, stringPattern_SK, instance = instance)
99string_SK
100"A_AA_A_AAA_A_A"
101
102!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103! Remove vector `pattern` from character array.
104!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105
106Array_SK
107"A ", "_ ", "A ", "_ ", "A ", "_ ", "A ", "_ ", "A ", "_ ", "A ", "_ ", "A ", "_ ", "A ", "_ ", "A "
108ArrayPattern_SK
109"_ "
110instance
111-3, +2, -4
112call setRemoved(Array_SK, ArrayPattern_SK, instance = instance)
113Array_SK
114"A ", "_ ", "A ", "A ", "_ ", "A ", "_ ", "A ", "A ", "A ", "_ ", "A ", "_ ", "A "
115
116!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117! Remove character array with scalar `pattern`.
118!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119
120Array_SK
121"A ", "_ ", "A ", "_ ", "A ", "_ ", "A ", "_ ", "A ", "_ ", "A ", "_ ", "A ", "_ ", "A ", "_ ", "A "
122ArrayPattern_SK(1)
123"_ "
124instance
125-3, +2, -4
126call setRemoved(Array_SK, ArrayPattern_SK(1), instance = instance)
127Array_SK
128"A ", "_ ", "A ", "A ", "_ ", "A ", "_ ", "A ", "A ", "A ", "_ ", "A ", "_ ", "A "
129
130!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131! Remove logical array with vector `pattern`.
132!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133
134Array_LK
135F, T, F, T, T, F, T, T, F, F
136ArrayPattern_LK
137F
138instance
139-3, +2, -4
140call setRemoved(Array_LK, ArrayPattern_LK, instance = instance)
141Array_LK
142F, T, T, T, T, T, F, F
143
144!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
145! Remove logical array with scalar `pattern`.
146!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147
148Array_LK
149F, T, F, T, T, F, T, T, F, F
150ArrayPattern_LK(1)
151F
152instance
153-3, +2, -4
154call setRemoved(Array_LK, ArrayPattern_LK(1), instance = instance)
155Array_LK
156F, T, T, T, T, T, F, F
157
158!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159! Remove integer array with vector `pattern`.
160!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161
162Array_IK
163+0, +1, +0, +2, +3, +0, +4, +5, +0, +0
164ArrayPattern_IK
165+0
166instance
167-3, +2, -4
168call setRemoved(Array_IK, ArrayPattern_IK, instance = instance)
169Array_IK
170+0, +1, +2, +3, +4, +5, +0, +0
171
172!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173! Remove integer array with scalar `pattern`.
174!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
175
176Array_IK
177+0, +1, +0, +2, +3, +0, +4, +5, +0, +0
178ArrayPattern_IK(1)
179+0
180instance
181-3, +2, -4
182call setRemoved(Array_IK, ArrayPattern_IK(1), instance = instance)
183Array_IK
184+0, +1, +2, +3, +4, +5, +0, +0
185
186!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
187! Remove complex array with vector `pattern`.
188!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
189
190Array_CK
191(+0.0000000000000000, -0.0000000000000000), (+1.0000000000000000, -1.0000000000000000), (+0.0000000000000000, -0.0000000000000000), (+2.0000000000000000, -2.0000000000000000), (+3.0000000000000000, -3.0000000000000000), (+0.0000000000000000, -0.0000000000000000), (+4.0000000000000000, -4.0000000000000000), (+5.0000000000000000, -5.0000000000000000), (+0.0000000000000000, -0.0000000000000000), (+0.0000000000000000, -0.0000000000000000)
192ArrayPattern_CK
193(+0.0000000000000000, -0.0000000000000000)
194instance
195-3, +2, -4
196call setRemoved(Array_CK, ArrayPattern_CK, instance = instance)
197Array_CK
198(+0.0000000000000000, -0.0000000000000000), (+1.0000000000000000, -1.0000000000000000), (+2.0000000000000000, -2.0000000000000000), (+3.0000000000000000, -3.0000000000000000), (+4.0000000000000000, -4.0000000000000000), (+5.0000000000000000, -5.0000000000000000), (+0.0000000000000000, -0.0000000000000000), (+0.0000000000000000, -0.0000000000000000)
199
200!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
201! Remove complex array with scalar `pattern`.
202!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203
204Array_CK
205(+0.0000000000000000, -0.0000000000000000), (+1.0000000000000000, -1.0000000000000000), (+0.0000000000000000, -0.0000000000000000), (+2.0000000000000000, -2.0000000000000000), (+3.0000000000000000, -3.0000000000000000), (+0.0000000000000000, -0.0000000000000000), (+4.0000000000000000, -4.0000000000000000), (+5.0000000000000000, -5.0000000000000000), (+0.0000000000000000, -0.0000000000000000), (+0.0000000000000000, -0.0000000000000000)
206ArrayPattern_CK(1)
207(+0.0000000000000000, -0.0000000000000000)
208instance
209-3, +2, -4
210call setRemoved(Array_CK, ArrayPattern_CK(1), instance = instance)
211Array_CK
212(+0.0000000000000000, -0.0000000000000000), (+1.0000000000000000, -1.0000000000000000), (+2.0000000000000000, -2.0000000000000000), (+3.0000000000000000, -3.0000000000000000), (+4.0000000000000000, -4.0000000000000000), (+5.0000000000000000, -5.0000000000000000), (+0.0000000000000000, -0.0000000000000000), (+0.0000000000000000, -0.0000000000000000)
213
214!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
215! Remove real array with vector `pattern`.
216!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
217
218Array_RK
219+0.0000000000000000, +1.0000000000000000, +0.0000000000000000, +2.0000000000000000, +3.0000000000000000, +0.0000000000000000, +4.0000000000000000, +5.0000000000000000, +0.0000000000000000, +0.0000000000000000
220ArrayPattern_RK
221+0.0000000000000000
222instance
223-3, +2, -4
224call setRemoved(Array_RK, ArrayPattern_RK, instance = instance)
225Array_RK
226+0.0000000000000000, +1.0000000000000000, +2.0000000000000000, +3.0000000000000000, +4.0000000000000000, +5.0000000000000000, +0.0000000000000000, +0.0000000000000000
227
228!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
229! Remove real array with scalar `pattern`.
230!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
231
232Array_RK
233+0.0000000000000000, +1.0000000000000000, +0.0000000000000000, +2.0000000000000000, +3.0000000000000000, +0.0000000000000000, +4.0000000000000000, +5.0000000000000000, +0.0000000000000000, +0.0000000000000000
234ArrayPattern_RK(1)
235+0.0000000000000000
236instance
237-3, +2, -4
238call setRemoved(Array_RK, ArrayPattern_RK(1), instance = instance)
239Array_RK
240+0.0000000000000000, +1.0000000000000000, +2.0000000000000000, +3.0000000000000000, +4.0000000000000000, +5.0000000000000000, +0.0000000000000000, +0.0000000000000000
241
242!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
244! Remove specific instances with a user-defined equivalence test.
245!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
247
248
249!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
250! Remove case-insensitive instances of vector `pattern` within the character array.
251!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
252
253string_SK
254"ABBAbbA"
255stringPattern_SK
256"bb"
257call setRemoved(string_SK, stringPattern_SK, iseq = iseq_SK) ! case-insensitive string removal.
258string_SK
259"AAA"
260
261!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
262! Remove specific instances of vector `pattern` within the real array.
263!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
264
265Array_RK
266+0.0000000000000000, +1.0100000000000000, +1.0400000000000000, +0.97999999999999998, +1.0000000000000000, +1.0200000000000000
267ArrayPattern_RK
268-1.0000000000000000, +1.0000000000000000
269instance
270-2
271call setRemoved(Array_RK, ArrayPattern_RK, iseq = iseq_vec_RK, instance = instance)
272Array_RK
273+0.0000000000000000, +0.97999999999999998, +1.0000000000000000, +1.0200000000000000
274
275!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
276! Remove specific instances of scalar `pattern` within the real array.
277!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
278
279Array_RK
280+0.0000000000000000, +1.0100000000000000, +1.0400000000000000, +0.97999999999999998, +1.0000000000000000, +1.0200000000000000
281ArrayPattern_RK(1)
282-1.0000000000000000
283instance
284-2
285call setRemoved(Array_RK, ArrayPattern_RK(1), iseq = iseq_RK, instance = instance)
286Array_RK
287+0.0000000000000000, +1.0100000000000000, +1.0400000000000000, +0.97999999999999998, +1.0200000000000000
288
289!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
290!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
291! Call to setRemoved() preserves the lower bound of the input `Array`.
292!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
293!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
294
295[lbound(Array_IK,1), ubound(Array_IK,1)]
296-7, -1
297Array_IK
298+1, +0, +2, +0, +3, +0, +4
299ArrayPattern_IK(1)
300+0
301call setRemoved(Array_IK, ArrayPattern_IK(1))
302Array_IK
303+1, +2, +3, +4
304[lbound(Array_IK,1), ubound(Array_IK,1)]
305-7, -4
306
Test:
test_pm_arrayRemove
Todo:
Low Priority: This generic interface can be extended to 2D input objects.


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:
Amir Shahmoradi, September 1, 2017, 12:00 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas Austin

Definition at line 3756 of file pm_arrayRemove.F90.


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