Skip to content

Commit 6015656

Browse files
authored
Merge branch 'master' into hash_functions2
2 parents dae5560 + e7f423a commit 6015656

29 files changed

+2686
-139
lines changed

.github/workflows/CI.yml

+8-11
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ jobs:
4545
with:
4646
python-version: 3.x
4747

48-
- name: Install CMake Linux
49-
if: contains(matrix.os, 'ubuntu')
50-
run: ci/install_cmake.sh
51-
5248
- name: Install fypp
5349
run: pip install --upgrade fypp
5450

@@ -88,7 +84,12 @@ jobs:
8884

8985
- name: test
9086
if: ${{ contains(matrix.build, 'cmake') }}
91-
run: ctest --test-dir ${{ env.BUILD_DIR }} --parallel --output-on-failure
87+
run: >-
88+
ctest
89+
--test-dir ${{ env.BUILD_DIR }}
90+
--parallel
91+
--output-on-failure
92+
--no-tests=error
9293
9394
- name: Install project
9495
if: ${{ contains(matrix.build, 'cmake') }}
@@ -101,7 +102,7 @@ jobs:
101102
make -f Makefile.manual test
102103
make -f Makefile.manual clean
103104
env:
104-
FYPPFLAGS: "-DMAXRANK=4"
105+
ADD_FYPPFLAGS: "-DMAXRANK=4"
105106

106107
intel-build:
107108
runs-on: ${{ matrix.os }}
@@ -130,10 +131,6 @@ jobs:
130131
with:
131132
python-version: 3.x
132133

133-
- name: Install CMake Linux
134-
if: contains(matrix.os, 'ubuntu')
135-
run: ci/install_cmake.sh
136-
137134
- name: Prepare for cache restore (OSX)
138135
if: contains(matrix.os, 'macos')
139136
run: |
@@ -205,7 +202,7 @@ jobs:
205202
if: failure()
206203

207204
- name: test
208-
run: ctest --parallel --output-on-failure
205+
run: ctest --parallel --output-on-failure --no-tests=error
209206
working-directory: build
210207

211208
- name: Install project

CHANGELOG.md

+25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Unreleased
22

3+
Features available from the latest git source
4+
5+
- new module `stdlib_distribution_uniform`
6+
[#272](https://github.com/fortran-lang/stdlib/pull/272)
7+
- new module `stdlib_selection`
8+
[#500](https://github.com/fortran-lang/stdlib/pull/500)
9+
- new procedures `select`, `arg_select`
10+
- new module `stdlib_version`
11+
[#579](https://github.com/fortran-lang/stdlib/pull/579)
12+
- new procedure `get_stdlib_version`
13+
- new module `stdlib_io_npy`
14+
[#581](https://github.com/fortran-lang/stdlib/pull/581)
15+
- new procedures `save_npy`, `load_npy`
16+
17+
Changes to existing modules
18+
19+
- change in module `stdlib_math`
20+
- `linspace` and `logspace` made pure
21+
[#549](https://github.com/fortran-lang/stdlib/pull/549)
22+
- change in module `stdlib_string_type`
23+
- `move` procedure made *pure*/*elemental*
24+
[#562](https://github.com/fortran-lang/stdlib/pull/562)
25+
- support for quadruple precision made optional
26+
[#565](https://github.com/fortran-lang/stdlib/pull/565)
27+
328

429
# Version 0.1.0
530

CONTRIBUTING.md

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ You are welcome to propose changes to the workflow by
8989
* Smaller PRs are better than large PRs, and will lead to a shorter review and
9090
merge cycle.
9191
* Add tests for your feature or bug fix to be sure that it stays functional and useful.
92+
* Include new features and changes in the
93+
[CHANGELOG](https://github.com/fortran-lang/stdlib/blob/master/CHANGELOG.md)
9294
* Be open to constructive criticism and requests for improving your code.
9395
* Again, please follow the
9496
[Fortran stdlib style guide](https://github.com/fortran-lang/stdlib/blob/master/STYLE_GUIDE.md).

Makefile.manual

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# Fortran stdlib Makefile
22

33
FC ?= gfortran
4-
FFLAGS ?= -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all -fno-range-check
5-
FYPPFLAGS ?=
4+
FFLAGS ?= -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all -fno-range-check
5+
ADD_FYPPFLAGS ?=
66

77
VERSION := $(subst ., ,$(file < VERSION))
8-
FYPPFLAGS += \
8+
VERSION_FYPPFLAGS += \
99
-DPROJECT_VERSION_MAJOR=$(word 1,$(VERSION)) \
1010
-DPROJECT_VERSION_MINOR=$(word 2,$(VERSION)) \
1111
-DPROJECT_VERSION_PATCH=$(word 3,$(VERSION))
1212

13+
FYPPFLAGS := $(ADD_FYPPFLAGS) $(VERSION_FYPPFLAGS)
14+
1315
export FC
1416
export FFLAGS
1517
export FYPPFLAGS

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ Alternatively, you can build using provided Makefiles:
176176
make -f Makefile.manual
177177
```
178178

179-
You can limit the maximum rank by setting ``-DMAXRANK=<num>`` in the ``FYPPFLAGS`` environment variable (which can reduce the compilation time):
179+
You can limit the maximum rank by setting ``-DMAXRANK=<num>`` in the ``ADD_FYPPFLAGS`` environment variable (which can reduce the compilation time):
180180

181181
```sh
182-
make -f Makefile.manual FYPPFLAGS=-DMAXRANK=4
182+
make -f Makefile.manual ADD_FYPPFLAGS=-DMAXRANK=4
183183
```
184184

185185
You can also specify the compiler and compiler-flags by setting the ``FC`` and ``FFLAGS`` environmental variables. Among other things, this facilitates use of compiler optimizations that are not specified in the Makefile.manual defaults.
186186
```sh
187-
make -f Makefile.manual FYPPFLAGS=-DMAXRANK=4 FC=gfortran FFLAGS="-O3 -flto"
187+
make -f Makefile.manual ADD_FYPPFLAGS=-DMAXRANK=4 FC=gfortran FFLAGS="-O3 -flto"
188188
```
189189

190190
### Build with [fortran-lang/fpm](https://github.com/fortran-lang/fpm)

ci/install_cmake.sh

-7
This file was deleted.

doc/specs/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ This is and index/directory of the specifications (specs) for each new module/fe
2727
- [sorting](./stdlib_sorting.html) - Sorting of rank one arrays
2828
- [stats](./stdlib_stats.html) - Descriptive Statistics
2929
- [stats_distributions_uniform](./stdlib_stats_distribution_uniform.html) - Uniform Probability Distribution
30+
- [stats_distributions_normal](./stdlib_stats_distribution_normal.html) - Normal Probability Distribution
3031
- [string\_type](./stdlib_string_type.html) - Basic string support
3132
- [strings](./stdlib_strings.html) - String handling and manipulation routines
3233
- [stringlist_type](./stdlib_stringlist_type.html) - 1-Dimensional list of strings

doc/specs/stdlib_io.md

+94-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ program demo_loadtxt
3636
use stdlib_io, only: loadtxt
3737
implicit none
3838
real, allocatable :: x(:,:)
39-
call loadtxt('example.dat', x)
39+
call loadtxt('example.dat', x)
4040
end program demo_loadtxt
4141
```
4242

@@ -128,6 +128,98 @@ program demo_savetxt
128128
use stdlib_io, only: savetxt
129129
implicit none
130130
real :: x(3,2) = 1
131-
call savetxt('example.dat', x)
131+
call savetxt('example.dat', x)
132132
end program demo_savetxt
133133
```
134+
135+
136+
## `load_npy`
137+
138+
### Status
139+
140+
Experimental
141+
142+
### Description
143+
144+
Loads an `array` from a npy formatted binary file.
145+
146+
### Syntax
147+
148+
`call [[stdlib_io_npy(module):load_npy(interface)]](filename, array[, iostat][, iomsg])`
149+
150+
### Arguments
151+
152+
`filename`: Shall be a character expression containing the file name from which to load the `array`.
153+
This argument is `intent(in)`.
154+
155+
`array`: Shall be an allocatable array of any rank of type `real`, `complex` or `integer`.
156+
This argument is `intent(out)`.
157+
158+
`iostat`: Default integer, contains status of loading to file, zero in case of success.
159+
It is an optional argument, in case not present the program will halt for non-zero status.
160+
This argument is `intent(out)`.
161+
162+
`iomsg`: Deferred length character value, contains error message in case `iostat` is non-zero.
163+
It is an optional argument, error message will be dropped if not present.
164+
This argument is `intent(out)`.
165+
166+
### Return value
167+
168+
Returns an allocated `array` with the content of `filename` in case of success.
169+
170+
### Example
171+
172+
```fortran
173+
program demo_loadnpy
174+
use stdlib_io_npy, only: load_npy
175+
implicit none
176+
real, allocatable :: x(:,:)
177+
call loadtxt('example.npy', x)
178+
end program demo_loadnpy
179+
```
180+
181+
182+
## `save_npy`
183+
184+
### Status
185+
186+
Experimental
187+
188+
### Description
189+
190+
Saves an `array` into a npy formatted binary file.
191+
192+
### Syntax
193+
194+
`call [[stdlib_io_npy(module):save_npy(interface)]](filename, array[, iostat][, iomsg])`
195+
196+
### Arguments
197+
198+
`filename`: Shall be a character expression containing the name of the file that will contain the `array`.
199+
This argument is `intent(in)`.
200+
201+
`array`: Shall be an array of any rank of type `real`, `complex` or `integer`.
202+
This argument is `intent(in)`.
203+
204+
`iostat`: Default integer, contains status of saving to file, zero in case of success.
205+
It is an optional argument, in case not present the program will halt for non-zero status.
206+
This argument is `intent(out)`.
207+
208+
`iomsg`: Deferred length character value, contains error message in case `iostat` is non-zero.
209+
It is an optional argument, error message will be dropped if not present.
210+
This argument is `intent(out)`.
211+
212+
### Output
213+
214+
Provides a npy file called `filename` that contains the rank-2 `array`.
215+
216+
### Example
217+
218+
```fortran
219+
program demo_savenpy
220+
use stdlib_io_npy, only: save_npy
221+
implicit none
222+
real :: x(3,2) = 1
223+
call save_npy('example.npy', x)
224+
end program demo_savenpy
225+
```

doc/specs/stdlib_selection.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ which implements selection algorithms.
2323
## Overview of the module
2424

2525
The module `stdlib_selection` defines two generic subroutines:
26+
2627
* `select` is used to find the k-th smallest entry of an array. The input
2728
array is also modified in-place, and on return will be partially sorted
2829
such that `all(array(1:k) <= array(k)))` and `all(array(k) <= array((k+1):size(array)))` is true.
@@ -159,7 +160,7 @@ Generic subroutine.
159160

160161
`array` : shall be a rank one array of any of the types:
161162
`integer(int8)`, `integer(int16)`, `integer(int32)`, `integer(int64)`,
162-
`real(sp)`, `real(dp)`, `real(xdp), `real(qp)`. It is an `intent(in)` argument. On input it is
163+
`real(sp)`, `real(dp)`, `real(xdp)`, `real(qp)`. It is an `intent(in)` argument. On input it is
163164
the array in which we search for the k-th smallest entry.
164165

165166
`indx`: shall be a rank one array with the same size as `array`, containing all integers
@@ -198,7 +199,7 @@ The code does not support `NaN` elements in `array`; it will run, but there is
198199
no consistent interpretation given to the order of `NaN` entries of `array`
199200
compared to other entries.
200201

201-
While it is essential that that `indx` contains a permutation of the integers `1:size(array)`,
202+
While it is essential that `indx` contains a permutation of the integers `1:size(array)`,
202203
the code does not check for this. For example if `size(array) == 4`, then we could have
203204
`indx = [4, 2, 1, 3]` or `indx = [1, 2, 3, 4]`, but not `indx = [2, 1, 2, 4]`. It is the user's
204205
responsibility to avoid such errors.

doc/specs/stdlib_stats.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ Generic subroutine
3232

3333
### Arguments
3434

35-
`array`: Shall be a rank-1 or a rank-2 array of type `integer`, `real`, or `complex`.
35+
`array`: Shall be a rank-1 or a rank-2 array of type `integer`, `real`, or `complex`. It is an `intent(in)` argument.
3636

37-
`dim`: Shall be a scalar of type `integer` with a value in the range from 1 to `n`, where `n` is the rank of `array`.
37+
`dim`: Shall be a scalar of type `integer` with a value in the range from 1 to `n`, where `n` is the rank of `array`. It is an `intent(in)` argument.
3838

39-
`mask` (optional): Shall be of type `logical` and either a scalar or an array of the same shape as `array`.
39+
`mask` (optional): Shall be of type `logical` and either a scalar or an array of the same shape as `array`. It is an `intent(in)` argument.
4040

4141
### Return value
4242

@@ -93,13 +93,13 @@ Generic subroutine
9393

9494
### Arguments
9595

96-
`array`: Shall be a rank-1 or a rank-2 array of type `integer`, `real`, or `complex`.
96+
`array`: Shall be a rank-1 or a rank-2 array of type `integer`, `real`, or `complex`. It is an `intent(in)` argument.
9797

98-
`dim`: Shall be a scalar of type `integer` with a value in the range from 1 to `n`, where `n` is the rank of `array`.
98+
`dim`: Shall be a scalar of type `integer` with a value in the range from 1 to `n`, where `n` is the rank of `array`. It is an `intent(in)` argument.
9999

100-
`mask` (optional): Shall be of type `logical` and either a scalar or an array of the same shape as `array`.
100+
`mask` (optional): Shall be of type `logical` and either a scalar or an array of the same shape as `array`. It is an `intent(in)` argument.
101101

102-
`corrected` (optional): Shall be a scalar of type `logical`. If `corrected` is `.true.` (default value), the sum is scaled with `n-1`. If `corrected` is `.false.`, then the sum is scaled with `n`.
102+
`corrected` (optional): Shall be a scalar of type `logical`. If `corrected` is `.true.` (default value), the sum is scaled with `n-1`. If `corrected` is `.false.`, then the sum is scaled with `n`. It is an `intent(in)` argument.
103103

104104
### Return value
105105

@@ -148,11 +148,11 @@ Generic subroutine
148148

149149
### Arguments
150150

151-
`array`: Shall be an array of type `integer`, `real`, or `complex`.
151+
`array`: Shall be an array of type `integer`, `real`, or `complex`. It is an `intent(in)` argument.
152152

153-
`dim`: Shall be a scalar of type `integer` with a value in the range from 1 to `n`, where `n` is the rank of `array`.
153+
`dim`: Shall be a scalar of type `integer` with a value in the range from 1 to `n`, where `n` is the rank of `array`. It is an `intent(in)` argument.
154154

155-
`mask` (optional): Shall be of type `logical` and either a scalar or an array of the same shape as `array`.
155+
`mask` (optional): Shall be of type `logical` and either a scalar or an array of the same shape as `array`. It is an `intent(in)` argument.
156156

157157
### Return value
158158

@@ -204,9 +204,9 @@ and if `n` is an odd number, the median is:
204204
median(array) = mean( array_sorted( floor( (n + 1) / 2.):floor( (n + 1) / 2.) + 1 ) )
205205
```
206206

207-
The current implementation is a quite naive implementation that relies on sorting
208-
the whole array, using the subroutine `[[stdlib_sorting(module):ord_sort(interface)]]`
209-
provided by the `[[stdlib_sorting(module)]]` module.
207+
The current implementation relies on a selection algorithm applied on a copy of
208+
the whole array, using the subroutine `[[stdlib_selection(module):select(interface)]]`
209+
provided by the `[[stdlib_selection(module)]]` module.
210210

211211
### Syntax
212212

@@ -220,11 +220,11 @@ Generic subroutine
220220

221221
### Arguments
222222

223-
`array`: Shall be an array of type `integer` or `real`.
223+
`array`: Shall be an array of type `integer` or `real`. It is an `intent(in)` argument.
224224

225-
`dim`: Shall be a scalar of type `integer` with a value in the range from 1 to `n`, where `n` is the rank of `array`.
225+
`dim`: Shall be a scalar of type `integer` with a value in the range from 1 to `n`, where `n` is the rank of `array`. It is an `intent(in)` argument.
226226

227-
`mask` (optional): Shall be of type `logical` and either a scalar or an array of the same shape as `array`.
227+
`mask` (optional): Shall be of type `logical` and either a scalar or an array of the same shape as `array`. It is an `intent(in)` argument.
228228

229229
### Return value
230230

@@ -360,13 +360,13 @@ Generic subroutine
360360

361361
### Arguments
362362

363-
`array`: Shall be an array of type `integer`, `real`, or `complex`.
363+
`array`: Shall be an array of type `integer`, `real`, or `complex`. It is an `intent(in)` argument.
364364

365-
`dim`: Shall be a scalar of type `integer` with a value in the range from 1 to `n`, where `n` is the rank of `array`.
365+
`dim`: Shall be a scalar of type `integer` with a value in the range from 1 to `n`, where `n` is the rank of `array`. It is an `intent(in)` argument.
366366

367-
`mask` (optional): Shall be of type `logical` and either a scalar or an array of the same shape as `array`.
367+
`mask` (optional): Shall be of type `logical` and either a scalar or an array of the same shape as `array`. It is an `intent(in)` argument.
368368

369-
`corrected` (optional): Shall be a scalar of type `logical`. If `corrected` is `.true.` (default value), the sum is scaled with `n-1`. If `corrected` is `.false.`, then the sum is scaled with `n`.
369+
`corrected` (optional): Shall be a scalar of type `logical`. If `corrected` is `.true.` (default value), the sum is scaled with `n-1`. If `corrected` is `.false.`, then the sum is scaled with `n`. It is an `intent(in)` argument.
370370

371371
### Return value
372372

0 commit comments

Comments
 (0)