Generate minimally-spaced character
, integer
, real
sequences or sequences at fixed intervals of size step
from start
to stop
.
- Parameters
-
[in] | start | : The input scalar of the same type and kind as the output range , representing the start point of the output range .
If start is of type character , then it must be of length type parameter 1 .
|
[in] | stop | : The input scalar of the same type and kind as the output range representing the end point of the output range .
If stop is of type character , then it must be of length type parameter 1 .
|
[in] | step | : The non-zero input scalar representing the size of the interval between adjacent values in the output range .
-
If
range is of type character , then step must have the default integer kind IK.
-
If
range is of type integer , or real then step must have the same type and kind parameter as range .
(optional, default = dynamically set to the smallest possible spacing between any two values between start and stop .
This means step = sign(1, stop - start) for output range of type character or integer and a variable step set by the intrinsic nearest(range(i), stop - start) for the element i of range.) |
- Returns
range
: The output allocatable
of
-
type
character
of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) of length type parameter 1
,
-
type
integer
of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64),
-
type
real
of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
containing the minimally or evenly -spaced sequence within the interval starting with start
and stop
.
Note that the specified value of stop
may not necessarily be the ending value in the sequence.
-
If
range
is of type character
, then range
has the shape (1 : 1 + (ichar(stop) - ichar(start)) / step)
.
-
If
range
is of type integer
, then range
has the shape (1 : 1 + (stop - start) / step)
.
-
If
range
is of type real
and step
is missing, then range
is an allocatable
of shape (:)
whose size is determined at runtime based on the real
number representation model of the computer.
-
If
range
is of type real
, then range
has the shape (1 : 1 + (stop - start) / step)
.
Possible calling interfaces ⛓
range(
1 :
1 + (
stop - start)
/ step)
= getRange(start, stop, step)
range(
1 :
1 + stop - start)
= getRange(start, stop)
range(
1 :
1 + (
stop - start)
/ step)
= getRange(start, stop, step)
range(
1 :
1 + ichar(stop)
- ichar(start))
= getRange(start, stop)
range(
1 :
1 + (
ichar(stop)
- ichar(start))
/ step)
= getRange(start, stop, step)
Generate minimally-spaced character, integer, real sequences or sequences at fixed intervals of size ...
This module contains procedures and generic interfaces for generating ranges of discrete character,...
- Warning
- The condition
step /= 0
must hold for the corresponding input arguments.
The condition len(stop) == 1
must hold for the corresponding input character
arguments.
The condition len(start) == 1
must hold for the corresponding input character
arguments.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1
.
-
Beware that the output
real
sequences with default minimum spacings with arbitrary start
and stop
can readily overflow the computer memory.
This is because the number of representable real
values between any two given start
and stop
is generally extremely large.
-
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.
- See also
- getRange
setRange
getLinSpace
setLinSpace
getLogSpace
setLogSpace
Example usage ⛓
10 type(display_type) :: disp
20 real,
allocatable ::
range(:)
23 call disp%show(
"range = getRange(0., 10 * nearest(0., 1.))")
24 range
= getRange(
0.,
10 * nearest(
0.,
1.))
26 call disp%show( range , deliml
= """" )
30 call disp%show(
"range = getRange(1., 1. + 10 * epsilon(1.))")
31 range
= getRange(
1.,
1. + 10 * epsilon(
1.))
33 call disp%show( range , deliml
= """" )
37 call disp%show(
"range = getRange(1., 1. - 10 * epsilon(1.))")
38 range
= getRange(
1.,
1. - 10 * epsilon(
1.))
40 call disp%show( range , deliml
= """" )
44 call disp%show(
"range = getRange(0., 9., 2.)")
47 call disp%show( range , deliml
= """" )
51 call disp%show(
"range = getRange(9., 0., -2.)")
54 call disp%show( range , deliml
= """" )
66 character(:),
allocatable :: range
69 call disp%show(
"range = getRange('A', 'Z')")
72 call disp%show( range , deliml
= """" )
76 call disp%show(
"range = getRange('A', 'Z', 2)")
79 call disp%show( range , deliml
= """" )
83 call disp%show(
"range = getRange('A', 'Z', 3)")
86 call disp%show( range , deliml
= """" )
90 call disp%show(
"range = getRange('A', 'z', 3)")
93 call disp%show( range , deliml
= """" )
97 call disp%show(
"range = getRange('Z', 'A', -2)")
100 call disp%show( range , deliml
= """" )
111 call disp%show(
"getRange(0_IKL, 10_IKL)")
114 call disp%show(
"getRange(0_IKL, 10_IKL, 2_IKL)")
117 call disp%show(
"getRange(0_IKL, 10_IKL, 3_IKL)")
124 call disp%show(
"getRange(10_IKL, 0_IKL, -2_IKL)")
127 call disp%show(
"getRange(10_IKL, 0_IKL, -3_IKL)")
138 call disp%show(
"getRange(0_IKS, 10_IKS)")
141 call disp%show(
"getRange(0_IKS, 10_IKS, 2_IKS)")
144 call disp%show(
"getRange(0_IKS, 10_IKS, 3_IKS)")
151 call disp%show(
"getRange(10_IKS, 0_IKS, -2_IKS)")
154 call disp%show(
"getRange(10_IKS, 0_IKS, -3_IKS)")
165 call disp%show(
"getRange(0_IKD, 10_IKD)")
168 call disp%show(
"getRange(0_IKD, 10_IKD, 2_IKD)")
171 call disp%show(
"getRange(0_IKD, 10_IKD, 3_IKD)")
178 call disp%show(
"getRange(10_IKD, 0_IKD, -2_IKD)")
181 call disp%show(
"getRange(10_IKD, 0_IKD, -3_IKD)")
192 call disp%show(
"getRange(0_IKH, 10_IKH)")
195 call disp%show(
"getRange(0_IKH, 10_IKH, 2_IKH)")
198 call disp%show(
"getRange(0_IKH, 10_IKH, 3_IKH)")
205 call disp%show(
"getRange(10_IKH, 0_IKH, -2_IKH)")
208 call disp%show(
"getRange(10_IKH, 0_IKH, -3_IKH)")
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 LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter IKS
The single-precision integer kind in Fortran mode. On most platforms, this is a 32-bit integer kind.
integer, parameter IKL
The scalar integer constant of intrinsic default kind, representing the lowest range integer kind typ...
integer, parameter IKH
The scalar integer constant of intrinsic default kind, representing the highest range integer kind ty...
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter IKD
The double precision integer kind in Fortran mode. On most platforms, this is a 64-bit integer kind.
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 ⛓
7range
= getRange(
0.,
10 * nearest(
0.,
1.))
9"+0.00000000",
"+0.140129846E-44",
"+0.280259693E-44",
"+0.420389539E-44",
"+0.560519386E-44",
"+0.700649232E-44",
"+0.840779079E-44",
"+0.980908925E-44",
"+0.112103877E-43",
"+0.126116862E-43",
"+0.140129846E-43"
12range
= getRange(
1.,
1. + 10 * epsilon(
1.))
14"+1.00000000",
"+1.00000012",
"+1.00000024",
"+1.00000036",
"+1.00000048",
"+1.00000060",
"+1.00000072",
"+1.00000083",
"+1.00000095",
"+1.00000107",
"+1.00000119"
17range
= getRange(
1.,
1. - 10 * epsilon(
1.))
19"+1.00000000",
"+0.999999940",
"+0.999999881",
"+0.999999821",
"+0.999999762",
"+0.999999702",
"+0.999999642",
"+0.999999583",
"+0.999999523",
"+0.999999464",
"+0.999999404",
"+0.999999344",
"+0.999999285",
"+0.999999225",
"+0.999999166",
"+0.999999106",
"+0.999999046",
"+0.999998987",
"+0.999998927",
"+0.999998868",
"+0.999998808"
24"+0.00000000",
"+2.00000000",
"+4.00000000",
"+6.00000000",
"+8.00000000"
29"+9.00000000",
"+7.00000000",
"+5.00000000",
"+3.00000000",
"+1.00000000"
39"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
68+0,
+1,
+2,
+3,
+4,
+5,
+6,
+7,
+8,
+9,
+10
71+0,
+2,
+4,
+6,
+8,
+10
78+10,
+8,
+6,
+4,
+2,
+0
90+0,
+1,
+2,
+3,
+4,
+5,
+6,
+7,
+8,
+9,
+10
93+0,
+2,
+4,
+6,
+8,
+10
100+10,
+8,
+6,
+4,
+2,
+0
112+0,
+1,
+2,
+3,
+4,
+5,
+6,
+7,
+8,
+9,
+10
115+0,
+2,
+4,
+6,
+8,
+10
122+10,
+8,
+6,
+4,
+2,
+0
134+0,
+1,
+2,
+3,
+4,
+5,
+6,
+7,
+8,
+9,
+10
137+0,
+2,
+4,
+6,
+8,
+10
144+10,
+8,
+6,
+4,
+2,
+0
- Test:
- test_pm_arrayRange
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, Tuesday 08:49 PM, August 10, 2021, Dallas, TX
Definition at line 135 of file pm_arrayRange.F90.