Skip to content

Commit

Permalink
Merge branch 'master' into revival_string_list
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-godara authored Aug 22, 2021
2 parents 2e5e822 + 5089a40 commit 45d6198
Show file tree
Hide file tree
Showing 23 changed files with 684 additions and 270 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ The following combinations are known to work, but they are not tested in the CI:

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

We try to test as many available compilers and platforms as possible.
A list of tested compilers which are currently not working and the respective issue are listed below.
Expand Down
40 changes: 1 addition & 39 deletions doc/specs/stdlib_ascii.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,42 +212,4 @@ program demo_reverse
implicit none
print'(a)', reverse("Hello, World!") ! returns "!dlroW ,olleH"
end program demo_reverse
```

### `to_string`

#### Status

Experimental

#### Description

Create a character string representing the value of the provided variable.

#### Syntax

`res = [[stdlib_ascii(module):to_string(interface)]] (string)`

#### Class

Pure function.

#### Argument

`val`: shall be an intrinsic integer or logical type. It is an `intent(in)` argument.

#### Result value

The result is an intrinsic character type.

#### Example

```fortran
program demo_string_value
use stdlib_ascii, only : to_string
implicit none
print'(a)', to_string(-3) ! returns "-3"
print'(a)', to_string(.true.) ! returns "T"
print'(a)', to_string(42) ! returns "42"
end program demo_string_value
```
```
68 changes: 68 additions & 0 deletions doc/specs/stdlib_math.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,71 @@ program demo_logspace_rstart_cbase
end program demo_logspace_rstart_cbase
```
## `arange`

### Status

Experimental

### Class

Pure function.

### Description

Creates a one-dimensional `array` of the `integer/real` type with fixed-spaced values of given spacing, within a given interval.

### Syntax

`result = [[stdlib_math(module):arange(interface)]](start [, end, step])`

### Arguments

All arguments should be the same type and kind.

`start`: Shall be an `integer/real` scalar.
This is an `intent(in)` argument.
The default `start` value is `1`.

`end`: Shall be an `integer/real` scalar.
This is an `intent(in)` and `optional` argument.
The default `end` value is the inputted `start` value.

`step`: Shall be an `integer/real` scalar and large than `0`.
This is an `intent(in)` and `optional` argument.
The default `step` value is `1`.

#### Warning
If `step = 0`, the `step` argument will be corrected to `1/1.0` by the internal process of the `arange` function.
If `step < 0`, the `step` argument will be corrected to `abs(step)` by the internal process of the `arange` function.

### Return value

Returns a one-dimensional `array` of fixed-spaced values.

For `integer` type arguments, the length of the result vector is `(end - start)/step + 1`.
For `real` type arguments, the length of the result vector is `floor((end - start)/step) + 1`.

### Example

```fortran
program demo_math_arange
use stdlib_math, only: arange
print *, arange(3) !! [1,2,3]
print *, arange(-1) !! [1,0,-1]
print *, arange(0,2) !! [0,1,2]
print *, arange(1,-1) !! [1,0,-1]
print *, arange(0, 2, 2) !! [0,2]
print *, arange(3.0) !! [1.0,2.0,3.0]
print *, arange(0.0,5.0) !! [0.0,1.0,2.0,3.0,4.0,5.0]
print *, arange(0.0,6.0,2.5) !! [0.0,2.5,5.0]
print *, (1.0,1.0)*arange(3) !! [(1.0,1.0),(2.0,2.0),[3.0,3.0]]
print *, arange(0.0,2.0,-2.0) !! [0.0,2.0]. Not recommended: `step` argument is negative!
print *, arange(0.0,2.0,0.0) !! [0.0,1.0,2.0]. Not recommended: `step` argument is zero!
end program demo_math_arange
```
69 changes: 69 additions & 0 deletions doc/specs/stdlib_strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,3 +538,72 @@ program demo_count
end program demo_count
```

<!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -->
### `to_string`

#### Description

Format or transfer a `integer/real/complex/logical` scalar as a string.
Input a wrong `format` that cause the internal-IO to fail, the result value is a string of `[*]`.

#### Syntax

`string = [[stdlib_strings(module):to_string(interface)]] (value [, format])`

#### Status

Experimental

#### Class

Pure function.

#### Argument

- `value`: Shall be an `integer/real/complex/logical` scalar.
This is an `intent(in)` argument.
- `format`: Shall be a `character(len=*)` scalar like `'(F6.2)'` or just `'F6.2'`.
This is an `intent(in)` and `optional` argument.
Contains the edit descriptor to format `value` into a string, for example `'(F6.2)'` or `'(f6.2)'`.
`to_string` will automatically enclose `format` in a set of parentheses, so passing `F6.2` or `f6.2` as `format` is possible as well.

#### Result value

The result is an `allocatable` length `character` scalar with up to `128` cached `character` length.

#### Example

```fortran
program demo_to_string
use stdlib_strings, only: to_string
!> Example for `complex` type
print *, to_string((1, 1)) !! "(1.00000000,1.00000000)"
print *, to_string((1, 1), '(F6.2)') !! "( 1.00, 1.00)"
print *, to_string((1000, 1), '(ES0.2)'), to_string((1000, 1), '(SP,F6.3)')
!! "(1.00E+3,1.00)""(******,+1.000)"
!! Too narrow formatter for real number
!! Normal demonstration(`******` from Fortran Standard)
!> Example for `integer` type
print *, to_string(-3) !! "-3"
print *, to_string(42, '(I4)') !! " 42"
print *, to_string(1, '(I0.4)'), to_string(2, '(B4)') !! "0001"" 10"
!> Example for `real` type
print *, to_string(1.) !! "1.00000000"
print *, to_string(1., '(F6.2)') !! " 1.00"
print *, to_string(1., 'F6.2') !! " 1.00"
print *, to_string(1., '(SP,ES9.2)'), to_string(1, '(F7.3)') !! "+1.00E+00""[*]"
!! 1 wrong demonstration (`[*]` from `to_string`)
!> Example for `logical` type
print *, to_string(.true.) !! "T"
print *, to_string(.true., '(L2)') !! " T"
print *, to_string(.true., 'L2') !! " T"
print *, to_string(.false., '(I5)') !! "[*]"
!! 1 wrong demonstrations(`[*]` from `to_string`)
end program demo_to_string
```
5 changes: 4 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ set(fppFiles
stdlib_math.fypp
stdlib_math_linspace.fypp
stdlib_math_logspace.fypp
stdlib_math_arange.fypp
stdlib_string_type.fypp
stdlib_string_type_constructor.fypp
stdlib_strings_to_string.fypp
stdlib_strings.fypp
)


Expand All @@ -51,7 +55,6 @@ set(SRC
stdlib_error.f90
stdlib_kinds.f90
stdlib_logger.f90
stdlib_strings.f90
stdlib_system.F90
stdlib_specialfunctions.f90
stdlib_specialfunctions_legendre.f90
Expand Down
117 changes: 64 additions & 53 deletions src/Makefile.manual
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SRCFYPP =\
SRCFYPP = \
stdlib_ascii.fypp \
stdlib_bitsets_64.fypp \
stdlib_bitsets_large.fypp \
Expand All @@ -7,6 +7,7 @@ SRCFYPP =\
stdlib_linalg.fypp \
stdlib_linalg_diag.fypp \
stdlib_linalg_outer_product.fypp \
stdlib_math_arange.fypp \
stdlib_optval.fypp \
stdlib_quadrature.fypp \
stdlib_quadrature_trapz.fypp \
Expand All @@ -26,10 +27,13 @@ SRCFYPP =\
stdlib_stats_moment_scalar.fypp \
stdlib_stats_var.fypp \
stdlib_math.fypp \
stdlib_math_linspace.fypp \
stdlib_math_logspace.fypp \
stdlib_math_linspace.fypp \
stdlib_math_logspace.fypp \
stdlib_stats_distribution_PRNG.fypp \
stdlib_string_type.fypp
stdlib_string_type.fypp \
stdlib_string_type_constructor.fypp \
stdlib_strings.fypp \
stdlib_strings_to_string.fypp

SRC = f18estop.f90 \
stdlib_error.f90 \
Expand Down Expand Up @@ -77,84 +81,91 @@ stdlib_error.o: stdlib_optval.o
stdlib_specialfunctions.o: stdlib_kinds.o
stdlib_specialfunctions_legendre.o: stdlib_kinds.o stdlib_specialfunctions.o
stdlib_io.o: \
stdlib_ascii.o \
stdlib_error.o \
stdlib_optval.o \
stdlib_kinds.o
stdlib_ascii.o \
stdlib_error.o \
stdlib_optval.o \
stdlib_kinds.o \
stdlib_ascii.o
stdlib_linalg.o: \
stdlib_kinds.o
stdlib_kinds.o
stdlib_linalg_diag.o: \
stdlib_linalg.o \
stdlib_kinds.o
stdlib_linalg.o \
stdlib_kinds.o
stdlib_logger.o: stdlib_ascii.o stdlib_optval.o
stdlib_optval.o: stdlib_kinds.o
stdlib_quadrature.o: stdlib_kinds.o

stdlib_quadrature_gauss.o: stdlib_kinds.o stdlib_quadrature.o

stdlib_quadrature_simps.o: \
stdlib_quadrature.o \
stdlib_error.o \
stdlib_kinds.o
stdlib_quadrature.o \
stdlib_error.o \
stdlib_kinds.o
stdlib_quadrature_trapz.o: \
stdlib_quadrature.o \
stdlib_error.o \
stdlib_kinds.o
stdlib_quadrature.o \
stdlib_error.o \
stdlib_kinds.o
stdlib_sorting.o: \
stdlib_kinds.o \
stdlib_string_type.o
stdlib_kinds.o \
stdlib_string_type.o
stdlib_sorting_ord_sort.o: \
stdlib_sorting.o
stdlib_sorting.o
stdlib_sorting_sort.o: \
stdlib_sorting.o
stdlib_sorting.o
stdlib_sorting_sort_index.o: \
stdlib_sorting.o
stdlib_sorting.o
stdlib_stats.o: \
stdlib_kinds.o
stdlib_kinds.o
stdlib_stats_corr.o: \
stdlib_optval.o \
stdlib_kinds.o \
stdlib_stats.o
stdlib_optval.o \
stdlib_kinds.o \
stdlib_stats.o
stdlib_stats_cov.o: \
stdlib_optval.o \
stdlib_kinds.o \
stdlib_stats.o
stdlib_optval.o \
stdlib_kinds.o \
stdlib_stats.o
stdlib_stats_mean.o: \
stdlib_optval.o \
stdlib_kinds.o \
stdlib_stats.o
stdlib_optval.o \
stdlib_kinds.o \
stdlib_stats.o
stdlib_stats_median.o: \
stdlib_optval.o \
stdlib_kinds.o \
stdlib_sorting.o \
stdlib_stats.o
stdlib_optval.o \
stdlib_kinds.o \
stdlib_sorting.o \
stdlib_stats.o
stdlib_stats_moment.o: \
stdlib_optval.o \
stdlib_kinds.o \
stdlib_stats.o
stdlib_optval.o \
stdlib_kinds.o \
stdlib_stats.o
stdlib_stats_moment_all.o: \
stdlib_stats_moment.o
stdlib_stats_moment.o
stdlib_stats_moment_mask.o: \
stdlib_stats_moment.o
stdlib_stats_moment.o
stdlib_stats_moment_scalar.o: \
stdlib_stats_moment.o
stdlib_stats_moment.o
stdlib_stats_var.o: \
stdlib_optval.o \
stdlib_kinds.o \
stdlib_stats.o
stdlib_optval.o \
stdlib_kinds.o \
stdlib_stats.o
stdlib_stats_distribution_PRNG.o: \
stdlib_kinds.o \
stdlib_error.o
stdlib_kinds.o \
stdlib_error.o
stdlib_string_type.o: stdlib_ascii.o \
stdlib_kinds.o
stdlib_string_type_constructor.o: stdlib_string_type.o \
stdlib_strings_to_string.o \
stdlib_strings.o
stdlib_strings.o: stdlib_ascii.o \
stdlib_string_type.o \
stdlib_optval.o
stdlib_math.o: stdlib_kinds.o
stdlib_optval.o \
stdlib_kinds.o
stdlib_strings_to_string.o: stdlib_strings.o
stdlib_math.o: stdlib_kinds.o \
stdlib_optval.o
stdlib_math_linspace.o: \
stdlib_math.o
stdlib_math.o
stdlib_math_logspace.o: \
stdlib_math_linspace.o
stdlib_math_linspace.o
stdlib_math_arange.o: \
stdlib_math.o
stdlib_linalg_outer_product.o: stdlib_linalg.o
stdlib_stringlist_type.o: stdlib_string_type.o \
stdlib_math.o \
Expand Down
Loading

0 comments on commit 45d6198

Please sign in to comment.