Skip to content

Commit f181750

Browse files
committed
Redirect some routines to STDLIB.
1 parent 13b78ef commit f181750

16 files changed

+1162
-1804
lines changed

Changelog.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# v1.0.2
2+
3+
- `forlab_stats`
4+
- redirect `mean`, `var` to `stdlib_stats`.
5+
- `forlab_io`
6+
- add `read_line` and `read_file`.
7+
- `forlab_math`
8+
- redirect `arange/is_close/all_close` to `stdlib_math`.

LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

33
Copyright (c) 2021 FORLAB Contributors
4+
Copyright (c) 2018-2021 Keurfon Luu
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

fpm.toml

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ test-drive = { git = "https://github.com/fortran-lang/test-drive" }
2323
[library]
2424
source-dir="src"
2525

26+
[install]
27+
library = true
28+
2629
#=========================== tests =============================================
2730
## [io] tests
2831
[[test]]

meta-src/forlab_math.fypp

+1-49
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module forlab_math
33

44
use stdlib_kinds, only: sp, dp, qp, int8, int16, int32, int64
55
use stdlib_optval, only: optval
6+
use stdlib_math, only: arange, is_close, all_close
67
implicit none
78
private
89

@@ -53,55 +54,6 @@ module forlab_math
5354
#:endfor
5455
end interface angle
5556

56-
!> Version: experimental
57-
!>
58-
!> Returns a boolean scalar/array where two scalar/arrays are element-wise equal within a tolerance.
59-
!> ([Specification](../page/specs/forlab_math.html#is_close))
60-
interface is_close
61-
#:set RC_KINDS_TYPES = REAL_KINDS_TYPES + CMPLX_KINDS_TYPES
62-
#:for k1, t1 in RC_KINDS_TYPES
63-
elemental module logical function is_close_${t1[0]}$${k1}$(a, b, rel_tol, abs_tol, equal_nan) result(close)
64-
${t1}$, intent(in) :: a, b
65-
real(${k1}$), intent(in), optional :: rel_tol, abs_tol
66-
logical, intent(in), optional :: equal_nan
67-
end function is_close_${t1[0]}$${k1}$
68-
#:endfor
69-
end interface is_close
70-
71-
!> Version: experimental
72-
!>
73-
!> Returns a boolean scalar where two arrays are element-wise equal within a tolerance.
74-
!> ([Specification](../page/specs/forlab_math.html#all_close))
75-
interface all_close
76-
#:set RC_KINDS_TYPES = REAL_KINDS_TYPES + CMPLX_KINDS_TYPES
77-
#:set RANKS = range(1, MAXRANK + 1)
78-
#:for k1, t1 in RC_KINDS_TYPES
79-
#:for r1 in RANKS
80-
logical pure module function all_close_${r1}$_${t1[0]}$${k1}$(a, b, rel_tol, abs_tol, equal_nan) result(close)
81-
${t1}$, intent(in) :: a${ranksuffix(r1)}$, b${ranksuffix(r1)}$
82-
real(${k1}$), intent(in), optional :: rel_tol, abs_tol
83-
logical, intent(in), optional :: equal_nan
84-
end function all_close_${r1}$_${t1[0]}$${k1}$
85-
#:endfor
86-
#:endfor
87-
end interface all_close
88-
89-
!> Version: experimental
90-
!>
91-
!> `arange` creates a rank-1 `array` of the `integer/real` type
92-
!> with fixed-spaced values of given spacing, within a given interval.
93-
!> ([Specification](../page/specs/forlab_math.html#arange))
94-
interface arange
95-
#:set RI_KINDS_TYPES = REAL_KINDS_TYPES + INT_KINDS_TYPES
96-
#:for k1, t1 in RI_KINDS_TYPES
97-
pure module function arange_${t1[0]}$_${k1}$(start, end, step) result(result)
98-
${t1}$, intent(in) :: start
99-
${t1}$, intent(in), optional :: end, step
100-
${t1}$, allocatable :: result(:)
101-
end function arange_${t1[0]}$_${k1}$
102-
#:endfor
103-
end interface arange
104-
10557
!> Version: experimental
10658
!>
10759
!> `signum` returns the sign of variables.

meta-src/forlab_math_all_close.fypp

-25
This file was deleted.

meta-src/forlab_math_arange.fypp

-54
This file was deleted.

meta-src/forlab_math_is_close.fypp

-43
This file was deleted.

meta-src/forlab_stats.fypp

+2-21
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,13 @@
33
module forlab_stats
44

55
use stdlib_kinds, only: sp, dp, qp, int8, int16, int32, int64
6+
use stdlib_stats, only: mean, var
67
implicit none
78
private
89

910
public :: mean, var, std
1011
public :: rng, randu, randn
1112

12-
interface mean
13-
!! mean computes the mean value of an array.
14-
#:for k1, t1 in REAL_KINDS_TYPES
15-
module function mean_1_${k1}$(x) result(mean)
16-
${t1}$, dimension(:), intent(in) :: x
17-
${t1}$ :: mean
18-
end function mean_1_${k1}$
19-
module function mean_2_${k1}$(A, dim) result(mean)
20-
${t1}$, dimension(:), allocatable :: mean
21-
${t1}$, dimension(:, :), intent(in) :: A
22-
integer, intent(in), optional :: dim
23-
end function mean_2_${k1}$
24-
#:endfor
25-
end interface mean
26-
2713
!> Version: Experimental
2814
!>
2915
!> Generate a normal distributed data scalar or vector.
@@ -67,16 +53,11 @@ module forlab_stats
6753
end subroutine rng
6854
end interface
6955

70-
#:set VSNAME = ['var', 'std']
56+
#:set VSNAME = ['std']
7157
#:for v1 in VSNAME
7258
interface ${v1}$
73-
#:if v1 == 'var'
74-
!! `var` computes vector and matrix variances.
75-
!!([Specification](../module/forlab_var.html))
76-
#:elif v1 == 'std'
7759
!! `std` computes vector and matrix standard deviations.
7860
!!([Specification](../module/forlab_var.html))
79-
#:endif
8061
#:for k1, t1 in REAL_KINDS_TYPES
8162
${t1}$ module function ${v1}$_1_${k1}$(x, w)
8263
${t1}$, dimension(:), intent(in) :: x

meta-src/forlab_stats_mean.fypp

-34
This file was deleted.

meta-src/forlab_stats_var.fypp

-65
This file was deleted.

0 commit comments

Comments
 (0)