10 #include "sll_assert.h"
11 #include "sll_working_precision.h"
37 #ifndef DOXYGEN_SHOULD_SKIP_THIS
40 function function_1d_legendre(x)
44 sll_real64 :: function_1d_legendre
45 sll_real64,
intent(in) :: x
46 end function function_1d_legendre
73 #define SELECT_CASES \
75 xk(1) = 0.0_f64; wk(1) = 2.0_f64; \
77 xk(1) = -1.0_f64/sqrt(3.0_f64); wk(1) = 1.0_f64; \
78 xk(2) = 1.0_f64/sqrt(3.0_f64); wk(2) = 1.0_f64; \
80 xk(1) = -sqrt(3.0_f64/5.0_f64); wk(1) = 5.0_f64/9.0_f64; \
81 xk(2) = 0.0_f64; wk(2) = 8.0_f64/9.0_f64; \
82 xk(3) = sqrt(3.0_f64/5.0_f64); wk(3) = 5.0_f64/9.0_f64; \
84 xk(1) = -sqrt((3.0_f64 + 2.0_f64*sqrt(6.0_f64/5.0_f64))/7.0_f64); \
85 xk(2) = -sqrt((3.0_f64 - 2.0_f64*sqrt(6.0_f64/5.0_f64))/7.0_f64); \
86 xk(3) = sqrt((3.0_f64 - 2.0_f64*sqrt(6.0_f64/5.0_f64))/7.0_f64); \
87 xk(4) = sqrt((3.0_f64 + 2.0_f64*sqrt(6.0_f64/5.0_f64))/7.0_f64); \
88 wk(1) = (18.0_f64 - sqrt(30.0_f64))/36.0_f64; \
89 wk(2) = (18.0_f64 + sqrt(30.0_f64))/36.0_f64; \
90 wk(3) = (18.0_f64 + sqrt(30.0_f64))/36.0_f64; \
91 wk(4) = (18.0_f64 - sqrt(30.0_f64))/36.0_f64; \
93 xk(1) = -0.9061798459386637_f64; wk(1) = 0.2369268850561887_f64; \
94 xk(2) = -0.5384693101056831_f64; wk(2) = 0.4786286704993665_f64; \
95 xk(3) = 0.0_f64; wk(3) = 0.5688888888888888_f64; \
96 xk(4) = 0.5384693101056831_f64; wk(4) = 0.4786286704993665_f64; \
97 xk(5) = 0.9061798459386637_f64; wk(5) = 0.2369268850561887_f64; \
99 xk(1) = -0.9324695142031524_f64; wk(1) = 0.1713244923791715_f64; \
100 xk(2) = -0.6612093864662643_f64; wk(2) = 0.3607615730481376_f64; \
101 xk(3) = -0.2386191860831966_f64; wk(3) = 0.4679139345726911_f64; \
102 xk(4) = 0.2386191860831966_f64; wk(4) = 0.4679139345726911_f64; \
103 xk(5) = 0.6612093864662643_f64; wk(5) = 0.3607615730481376_f64; \
104 xk(6) = 0.9324695142031524_f64; wk(6) = 0.1713244923791715_f64; \
106 xk(1) = -0.9491079123427587_f64; wk(1) = 0.1294849661688697_f64; \
107 xk(2) = -0.7415311855993930_f64; wk(2) = 0.2797053914892763_f64; \
108 xk(3) = -0.4058451513773973_f64; wk(3) = 0.3818300505051193_f64; \
109 xk(4) = 0._f64; wk(4) = 0.41795918367346824_f64; \
110 xk(5) = 0.4058451513773973_f64; wk(5) = 0.3818300505051193_f64; \
111 xk(6) = 0.7415311855993930_f64; wk(6) = 0.2797053914892763_f64; \
112 xk(7) = 0.9491079123427587_f64; wk(7) = 0.1294849661688697_f64; \
114 xk(1) = -0.9602898564975370_f64; wk(1) = 0.10122853629037747_f64; \
115 xk(2) = -0.7966664774136267_f64; wk(2) = 0.22238103445337337_f64; \
116 xk(3) = -0.5255324099163288_f64; wk(3) = 0.31370664587788677_f64; \
117 xk(4) = -0.1834346424956503_f64; wk(4) = 0.36268378337836155_f64; \
118 xk(5) = 0.1834346424956503_f64; wk(5) = 0.36268378337836155_f64; \
119 xk(6) = 0.5255324099163288_f64; wk(6) = 0.31370664587788677_f64; \
120 xk(7) = 0.7966664774136267_f64; wk(7) = 0.22238103445337337_f64; \
121 xk(8) = 0.9602898564975370_f64; wk(8) = 0.10122853629037747_f64; \
123 xk(1) = -0.968160239507626_f64; wk(1) = 0.081274388361574_f64; \
124 xk(2) = -0.836031107326636_f64; wk(2) = 0.180648160694857_f64; \
125 xk(3) = -0.613371432700590_f64; wk(3) = 0.260610696402935_f64; \
126 xk(4) = -0.324253423403809_f64; wk(4) = 0.312347077040003_f64; \
127 xk(5) = 0.0_f64; wk(5) = 0.330239355001260_f64; \
128 xk(6) = 0.324253423403809_f64; wk(6) = 0.312347077040003_f64; \
129 xk(7) = 0.613371432700590_f64; wk(7) = 0.260610696402935_f64; \
130 xk(8) = 0.836031107326636_f64; wk(8) = 0.180648160694857_f64; \
131 xk(9) = 0.968160239507626_f64; wk(9) = 0.081274388361574_f64; \
133 xk(1) = -0.973906528517172_f64; wk(1) = 0.066671344308688_f64; \
134 xk(2) = -0.865063366688985_f64; wk(2) = 0.149451349150581_f64; \
135 xk(3) = -0.679409568299024_f64; wk(3) = 0.219086362515982_f64; \
136 xk(4) = -0.433395394129247_f64; wk(4) = 0.269266719309996_f64; \
137 xk(5) = -0.148874338981631_f64; wk(5) = 0.295524224714753_f64; \
138 xk(6) = 0.148874338981631_f64; wk(6) = 0.295524224714753_f64; \
139 xk(7) = 0.433395394129247_f64; wk(7) = 0.269266719309996_f64; \
140 xk(8) = 0.679409568299024_f64; wk(8) = 0.219086362515982_f64; \
141 xk(9) = 0.865063366688985_f64; wk(9) = 0.149451349150581_f64; \
142 xk(10) = 0.973906528517172_f64; wk(10) = 0.066671344308688_f64; \
144 print *,
'sll_m_gauss_legendre_integration: '; \
145 print *,
'degree of integration not implemented. Exiting...'; \
167 procedure(function_1d_legendre) :: f
168 sll_real64,
intent(in) :: a
169 sll_real64,
intent(in) :: b
170 sll_int32,
intent(in) :: n
171 sll_real64,
dimension(1:10) :: xk
172 sll_real64,
dimension(1:10) :: wk
189 ans = ans + f(x)*wk(k)
265 sll_int32,
intent(in) :: npoints
266 sll_real64,
intent(in),
optional :: a
267 sll_real64,
intent(in),
optional :: b
268 sll_real64,
dimension(2, 1:npoints) :: xw
269 sll_real64,
dimension(1:npoints) :: xk
270 sll_real64,
dimension(1:npoints) :: wk
275 sll_assert(npoints >= 1)
281 select case (npoints)
285 if (
present(a) .and.
present(b))
then
290 xw(1, k) = c1*xk(k) + c2
294 xw(1, 1:npoints) = xk(1:npoints)
295 xw(2, 1:npoints) = wk(1:npoints)
301 sll_int32,
intent(in) :: npoints
302 sll_real64,
intent(in),
optional :: a
303 sll_real64,
intent(in),
optional :: b
304 sll_real64,
dimension(1:npoints) :: xw
305 sll_real64,
dimension(1:npoints) :: xk
306 sll_real64,
dimension(1:npoints) :: wk
311 sll_assert(npoints >= 1)
317 select case (npoints)
321 if (
present(a) .and.
present(b))
then
326 xw(k) = c1*xk(k) + c2
329 xw(1:npoints) = xk(1:npoints)
335 sll_int32,
intent(in) :: npoints
336 sll_real64,
intent(in),
optional :: a
337 sll_real64,
intent(in),
optional :: b
338 sll_real64,
dimension(1:npoints) :: xw
339 sll_real64,
dimension(1:npoints) :: xk
340 sll_real64,
dimension(1:npoints) :: wk
345 sll_assert(npoints >= 1)
351 select case (npoints)
355 if (
present(a) .and.
present(b))
then
363 xw(1:npoints) = wk(1:npoints)
Compute numerical integration with Gauss-Legendre formula.
Gauss-Legendre integration.
real(kind=f64) function, dimension(2, 1:npoints), public sll_f_gauss_legendre_points_and_weights(npoints, a, b)
Returns a 2d array of size (2,npoints) containing gauss-legendre points and weights in the interval [...
real(kind=f64) function, dimension(1:npoints), public sll_f_gauss_legendre_points(npoints, a, b)
real(kind=f64) function, dimension(1:npoints), public sll_f_gauss_legendre_weights(npoints, a, b)
real(kind=f64) function gauss_legendre_integral_1d(f, a, b, n)
Gauss-Legendre Quadrature.
Module to select the kind parameter.