Skip to content

Commit 45d6198

Browse files
authored
Merge branch 'master' into revival_string_list
2 parents 2e5e822 + 5089a40 commit 45d6198

23 files changed

+684
-270
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ The following combinations are known to work, but they are not tested in the CI:
9898

9999
Name | Version | Platform | Architecture
100100
--- | --- | --- | ---
101-
GCC Fortran (MinGW) | 8.4.0, 9.3.0, 10.2.0 | Windows 10 | x86_64, i686
101+
GCC Fortran (MinGW) | 9.3.0, 10.2.0, 11.2.0 | Windows 10 | x86_64, i686
102102

103103
We try to test as many available compilers and platforms as possible.
104104
A list of tested compilers which are currently not working and the respective issue are listed below.

Diff for: doc/specs/stdlib_ascii.md

+1-39
Original file line numberDiff line numberDiff line change
@@ -212,42 +212,4 @@ program demo_reverse
212212
implicit none
213213
print'(a)', reverse("Hello, World!") ! returns "!dlroW ,olleH"
214214
end program demo_reverse
215-
```
216-
217-
### `to_string`
218-
219-
#### Status
220-
221-
Experimental
222-
223-
#### Description
224-
225-
Create a character string representing the value of the provided variable.
226-
227-
#### Syntax
228-
229-
`res = [[stdlib_ascii(module):to_string(interface)]] (string)`
230-
231-
#### Class
232-
233-
Pure function.
234-
235-
#### Argument
236-
237-
`val`: shall be an intrinsic integer or logical type. It is an `intent(in)` argument.
238-
239-
#### Result value
240-
241-
The result is an intrinsic character type.
242-
243-
#### Example
244-
245-
```fortran
246-
program demo_string_value
247-
use stdlib_ascii, only : to_string
248-
implicit none
249-
print'(a)', to_string(-3) ! returns "-3"
250-
print'(a)', to_string(.true.) ! returns "T"
251-
print'(a)', to_string(42) ! returns "42"
252-
end program demo_string_value
253-
```
215+
```

Diff for: doc/specs/stdlib_math.md

+68
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,71 @@ program demo_logspace_rstart_cbase
275275
276276
end program demo_logspace_rstart_cbase
277277
```
278+
## `arange`
279+
280+
### Status
281+
282+
Experimental
283+
284+
### Class
285+
286+
Pure function.
287+
288+
### Description
289+
290+
Creates a one-dimensional `array` of the `integer/real` type with fixed-spaced values of given spacing, within a given interval.
291+
292+
### Syntax
293+
294+
`result = [[stdlib_math(module):arange(interface)]](start [, end, step])`
295+
296+
### Arguments
297+
298+
All arguments should be the same type and kind.
299+
300+
`start`: Shall be an `integer/real` scalar.
301+
This is an `intent(in)` argument.
302+
The default `start` value is `1`.
303+
304+
`end`: Shall be an `integer/real` scalar.
305+
This is an `intent(in)` and `optional` argument.
306+
The default `end` value is the inputted `start` value.
307+
308+
`step`: Shall be an `integer/real` scalar and large than `0`.
309+
This is an `intent(in)` and `optional` argument.
310+
The default `step` value is `1`.
311+
312+
#### Warning
313+
If `step = 0`, the `step` argument will be corrected to `1/1.0` by the internal process of the `arange` function.
314+
If `step < 0`, the `step` argument will be corrected to `abs(step)` by the internal process of the `arange` function.
315+
316+
### Return value
317+
318+
Returns a one-dimensional `array` of fixed-spaced values.
319+
320+
For `integer` type arguments, the length of the result vector is `(end - start)/step + 1`.
321+
For `real` type arguments, the length of the result vector is `floor((end - start)/step) + 1`.
322+
323+
### Example
324+
325+
```fortran
326+
program demo_math_arange
327+
use stdlib_math, only: arange
328+
329+
print *, arange(3) !! [1,2,3]
330+
print *, arange(-1) !! [1,0,-1]
331+
print *, arange(0,2) !! [0,1,2]
332+
print *, arange(1,-1) !! [1,0,-1]
333+
print *, arange(0, 2, 2) !! [0,2]
334+
335+
print *, arange(3.0) !! [1.0,2.0,3.0]
336+
print *, arange(0.0,5.0) !! [0.0,1.0,2.0,3.0,4.0,5.0]
337+
print *, arange(0.0,6.0,2.5) !! [0.0,2.5,5.0]
338+
339+
print *, (1.0,1.0)*arange(3) !! [(1.0,1.0),(2.0,2.0),[3.0,3.0]]
340+
341+
print *, arange(0.0,2.0,-2.0) !! [0.0,2.0]. Not recommended: `step` argument is negative!
342+
print *, arange(0.0,2.0,0.0) !! [0.0,1.0,2.0]. Not recommended: `step` argument is zero!
343+
344+
end program demo_math_arange
345+
```

Diff for: doc/specs/stdlib_strings.md

+69
Original file line numberDiff line numberDiff line change
@@ -538,3 +538,72 @@ program demo_count
538538
539539
end program demo_count
540540
```
541+
542+
<!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -->
543+
### `to_string`
544+
545+
#### Description
546+
547+
Format or transfer a `integer/real/complex/logical` scalar as a string.
548+
Input a wrong `format` that cause the internal-IO to fail, the result value is a string of `[*]`.
549+
550+
#### Syntax
551+
552+
`string = [[stdlib_strings(module):to_string(interface)]] (value [, format])`
553+
554+
#### Status
555+
556+
Experimental
557+
558+
#### Class
559+
560+
Pure function.
561+
562+
#### Argument
563+
564+
- `value`: Shall be an `integer/real/complex/logical` scalar.
565+
This is an `intent(in)` argument.
566+
- `format`: Shall be a `character(len=*)` scalar like `'(F6.2)'` or just `'F6.2'`.
567+
This is an `intent(in)` and `optional` argument.
568+
Contains the edit descriptor to format `value` into a string, for example `'(F6.2)'` or `'(f6.2)'`.
569+
`to_string` will automatically enclose `format` in a set of parentheses, so passing `F6.2` or `f6.2` as `format` is possible as well.
570+
571+
#### Result value
572+
573+
The result is an `allocatable` length `character` scalar with up to `128` cached `character` length.
574+
575+
#### Example
576+
577+
```fortran
578+
program demo_to_string
579+
use stdlib_strings, only: to_string
580+
581+
!> Example for `complex` type
582+
print *, to_string((1, 1)) !! "(1.00000000,1.00000000)"
583+
print *, to_string((1, 1), '(F6.2)') !! "( 1.00, 1.00)"
584+
print *, to_string((1000, 1), '(ES0.2)'), to_string((1000, 1), '(SP,F6.3)')
585+
!! "(1.00E+3,1.00)""(******,+1.000)"
586+
!! Too narrow formatter for real number
587+
!! Normal demonstration(`******` from Fortran Standard)
588+
589+
!> Example for `integer` type
590+
print *, to_string(-3) !! "-3"
591+
print *, to_string(42, '(I4)') !! " 42"
592+
print *, to_string(1, '(I0.4)'), to_string(2, '(B4)') !! "0001"" 10"
593+
594+
!> Example for `real` type
595+
print *, to_string(1.) !! "1.00000000"
596+
print *, to_string(1., '(F6.2)') !! " 1.00"
597+
print *, to_string(1., 'F6.2') !! " 1.00"
598+
print *, to_string(1., '(SP,ES9.2)'), to_string(1, '(F7.3)') !! "+1.00E+00""[*]"
599+
!! 1 wrong demonstration (`[*]` from `to_string`)
600+
601+
!> Example for `logical` type
602+
print *, to_string(.true.) !! "T"
603+
print *, to_string(.true., '(L2)') !! " T"
604+
print *, to_string(.true., 'L2') !! " T"
605+
print *, to_string(.false., '(I5)') !! "[*]"
606+
!! 1 wrong demonstrations(`[*]` from `to_string`)
607+
608+
end program demo_to_string
609+
```

Diff for: src/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ set(fppFiles
3232
stdlib_math.fypp
3333
stdlib_math_linspace.fypp
3434
stdlib_math_logspace.fypp
35+
stdlib_math_arange.fypp
3536
stdlib_string_type.fypp
37+
stdlib_string_type_constructor.fypp
38+
stdlib_strings_to_string.fypp
39+
stdlib_strings.fypp
3640
)
3741

3842

@@ -51,7 +55,6 @@ set(SRC
5155
stdlib_error.f90
5256
stdlib_kinds.f90
5357
stdlib_logger.f90
54-
stdlib_strings.f90
5558
stdlib_system.F90
5659
stdlib_specialfunctions.f90
5760
stdlib_specialfunctions_legendre.f90

Diff for: src/Makefile.manual

+64-53
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SRCFYPP =\
1+
SRCFYPP = \
22
stdlib_ascii.fypp \
33
stdlib_bitsets_64.fypp \
44
stdlib_bitsets_large.fypp \
@@ -7,6 +7,7 @@ SRCFYPP =\
77
stdlib_linalg.fypp \
88
stdlib_linalg_diag.fypp \
99
stdlib_linalg_outer_product.fypp \
10+
stdlib_math_arange.fypp \
1011
stdlib_optval.fypp \
1112
stdlib_quadrature.fypp \
1213
stdlib_quadrature_trapz.fypp \
@@ -26,10 +27,13 @@ SRCFYPP =\
2627
stdlib_stats_moment_scalar.fypp \
2728
stdlib_stats_var.fypp \
2829
stdlib_math.fypp \
29-
stdlib_math_linspace.fypp \
30-
stdlib_math_logspace.fypp \
30+
stdlib_math_linspace.fypp \
31+
stdlib_math_logspace.fypp \
3132
stdlib_stats_distribution_PRNG.fypp \
32-
stdlib_string_type.fypp
33+
stdlib_string_type.fypp \
34+
stdlib_string_type_constructor.fypp \
35+
stdlib_strings.fypp \
36+
stdlib_strings_to_string.fypp
3337

3438
SRC = f18estop.f90 \
3539
stdlib_error.f90 \
@@ -77,84 +81,91 @@ stdlib_error.o: stdlib_optval.o
7781
stdlib_specialfunctions.o: stdlib_kinds.o
7882
stdlib_specialfunctions_legendre.o: stdlib_kinds.o stdlib_specialfunctions.o
7983
stdlib_io.o: \
80-
stdlib_ascii.o \
81-
stdlib_error.o \
82-
stdlib_optval.o \
83-
stdlib_kinds.o
84+
stdlib_ascii.o \
85+
stdlib_error.o \
86+
stdlib_optval.o \
87+
stdlib_kinds.o \
88+
stdlib_ascii.o
8489
stdlib_linalg.o: \
85-
stdlib_kinds.o
90+
stdlib_kinds.o
8691
stdlib_linalg_diag.o: \
87-
stdlib_linalg.o \
88-
stdlib_kinds.o
92+
stdlib_linalg.o \
93+
stdlib_kinds.o
8994
stdlib_logger.o: stdlib_ascii.o stdlib_optval.o
9095
stdlib_optval.o: stdlib_kinds.o
9196
stdlib_quadrature.o: stdlib_kinds.o
92-
9397
stdlib_quadrature_gauss.o: stdlib_kinds.o stdlib_quadrature.o
94-
9598
stdlib_quadrature_simps.o: \
96-
stdlib_quadrature.o \
97-
stdlib_error.o \
98-
stdlib_kinds.o
99+
stdlib_quadrature.o \
100+
stdlib_error.o \
101+
stdlib_kinds.o
99102
stdlib_quadrature_trapz.o: \
100-
stdlib_quadrature.o \
101-
stdlib_error.o \
102-
stdlib_kinds.o
103+
stdlib_quadrature.o \
104+
stdlib_error.o \
105+
stdlib_kinds.o
103106
stdlib_sorting.o: \
104-
stdlib_kinds.o \
105-
stdlib_string_type.o
107+
stdlib_kinds.o \
108+
stdlib_string_type.o
106109
stdlib_sorting_ord_sort.o: \
107-
stdlib_sorting.o
110+
stdlib_sorting.o
108111
stdlib_sorting_sort.o: \
109-
stdlib_sorting.o
112+
stdlib_sorting.o
110113
stdlib_sorting_sort_index.o: \
111-
stdlib_sorting.o
114+
stdlib_sorting.o
112115
stdlib_stats.o: \
113-
stdlib_kinds.o
116+
stdlib_kinds.o
114117
stdlib_stats_corr.o: \
115-
stdlib_optval.o \
116-
stdlib_kinds.o \
117-
stdlib_stats.o
118+
stdlib_optval.o \
119+
stdlib_kinds.o \
120+
stdlib_stats.o
118121
stdlib_stats_cov.o: \
119-
stdlib_optval.o \
120-
stdlib_kinds.o \
121-
stdlib_stats.o
122+
stdlib_optval.o \
123+
stdlib_kinds.o \
124+
stdlib_stats.o
122125
stdlib_stats_mean.o: \
123-
stdlib_optval.o \
124-
stdlib_kinds.o \
125-
stdlib_stats.o
126+
stdlib_optval.o \
127+
stdlib_kinds.o \
128+
stdlib_stats.o
126129
stdlib_stats_median.o: \
127-
stdlib_optval.o \
128-
stdlib_kinds.o \
129-
stdlib_sorting.o \
130-
stdlib_stats.o
130+
stdlib_optval.o \
131+
stdlib_kinds.o \
132+
stdlib_sorting.o \
133+
stdlib_stats.o
131134
stdlib_stats_moment.o: \
132-
stdlib_optval.o \
133-
stdlib_kinds.o \
134-
stdlib_stats.o
135+
stdlib_optval.o \
136+
stdlib_kinds.o \
137+
stdlib_stats.o
135138
stdlib_stats_moment_all.o: \
136-
stdlib_stats_moment.o
139+
stdlib_stats_moment.o
137140
stdlib_stats_moment_mask.o: \
138-
stdlib_stats_moment.o
141+
stdlib_stats_moment.o
139142
stdlib_stats_moment_scalar.o: \
140-
stdlib_stats_moment.o
143+
stdlib_stats_moment.o
141144
stdlib_stats_var.o: \
142-
stdlib_optval.o \
143-
stdlib_kinds.o \
144-
stdlib_stats.o
145+
stdlib_optval.o \
146+
stdlib_kinds.o \
147+
stdlib_stats.o
145148
stdlib_stats_distribution_PRNG.o: \
146-
stdlib_kinds.o \
147-
stdlib_error.o
149+
stdlib_kinds.o \
150+
stdlib_error.o
148151
stdlib_string_type.o: stdlib_ascii.o \
149152
stdlib_kinds.o
153+
stdlib_string_type_constructor.o: stdlib_string_type.o \
154+
stdlib_strings_to_string.o \
155+
stdlib_strings.o
150156
stdlib_strings.o: stdlib_ascii.o \
151157
stdlib_string_type.o \
152-
stdlib_optval.o
153-
stdlib_math.o: stdlib_kinds.o
158+
stdlib_optval.o \
159+
stdlib_kinds.o
160+
stdlib_strings_to_string.o: stdlib_strings.o
161+
stdlib_math.o: stdlib_kinds.o \
162+
stdlib_optval.o
154163
stdlib_math_linspace.o: \
155-
stdlib_math.o
164+
stdlib_math.o
156165
stdlib_math_logspace.o: \
157-
stdlib_math_linspace.o
166+
stdlib_math_linspace.o
167+
stdlib_math_arange.o: \
168+
stdlib_math.o
158169
stdlib_linalg_outer_product.o: stdlib_linalg.o
159170
stdlib_stringlist_type.o: stdlib_string_type.o \
160171
stdlib_math.o \

0 commit comments

Comments
 (0)