Skip to content

Commit 52386a6

Browse files
committed
Add simpson's rule API (not implemented)
1 parent 32546f1 commit 52386a6

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

src/stdlib_experimental_quadrature.fypp

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ module stdlib_experimental_quadrature
66
implicit none
77

88
private
9-
public :: trapz, trapz_weights
9+
10+
! array integration
11+
public :: trapz
12+
public :: trapz_weights
13+
public :: simps
14+
public :: simps_weights
15+
1016

1117
interface trapz
1218
#:for KIND in REAL_KINDS
@@ -25,6 +31,7 @@ module stdlib_experimental_quadrature
2531
#:endfor
2632
end interface trapz
2733

34+
2835
interface trapz_weights
2936
#:for KIND in REAL_KINDS
3037
pure module function trapz_weights_${KIND}$(x) result(w)
@@ -34,4 +41,35 @@ module stdlib_experimental_quadrature
3441
#:endfor
3542
end interface trapz_weights
3643

44+
45+
interface simps
46+
#:for KIND in REAL_KINDS
47+
pure module function simps_dx_${KIND}$(y, dx, even) result(integral)
48+
real(${KIND}$), dimension(:), intent(in) :: y
49+
real(${KIND}$), intent(in) :: dx
50+
integer, intent(in), optional :: even
51+
real(${KIND}$) :: integral
52+
end function simps_dx_${KIND}$
53+
#:endfor
54+
#:for KIND in REAL_KINDS
55+
pure module function simps_x_${KIND}$(y, x, even) result(integral)
56+
real(${KIND}$), dimension(:), intent(in) :: y
57+
real(${KIND}$), dimension(size(y)), intent(in) :: x
58+
integer, intent(in), optional :: even
59+
real(${KIND}$) :: integral
60+
end function simps_x_${KIND}$
61+
#:endfor
62+
end interface simps
63+
64+
65+
interface simps_weights
66+
#:for KIND in REAL_KINDS
67+
pure module function simps_weights_${KIND}$(x, even) result(w)
68+
real(${KIND}$), dimension(:), intent(in) :: x
69+
real(${KIND}$), dimension(size(x)) :: w
70+
integer, intent(in), optional :: even
71+
end function simps_weights_${KIND}$
72+
#:endfor
73+
end interface simps_weights
74+
3775
end module stdlib_experimental_quadrature

0 commit comments

Comments
 (0)