10 #include "sll_working_precision.h"
24 #ifndef DOXYGEN_SHOULD_SKIP_THIS
27 function function_1d(x)
31 sll_real64 :: function_1d
32 sll_real64,
intent(in) :: x
33 end function function_1d
63 procedure(function_1d) :: f
64 sll_real64,
intent(in) :: a
65 sll_real64,
intent(in) :: b
66 sll_int32,
intent(in) :: n
67 sll_real64,
dimension(n) :: xk
68 sll_real64,
dimension(n) :: wk
71 sll_real64 :: alpha(0:n - 1), beta(0:n - 1)
72 sll_real64 :: de(n), da(n), db(n)
83 beta(k) = real(k**2, f64)/real((2*k + 1)*(2*k - 1), f64)
91 call dlob(n - 2, alpha, beta, -1.0_f64, 1.0_f64, xk, wk, err, de, da, db)
103 ans = ans + f(xk(k))*wk(k)
116 sll_int32,
intent(in) :: n
117 sll_real64,
intent(in),
optional :: a
118 sll_real64,
intent(in),
optional :: b
119 sll_real64,
dimension(2, n) :: wx
133 sll_int32,
intent(in) :: n
134 sll_real64,
intent(in),
optional :: a
135 sll_real64,
intent(in),
optional :: b
136 sll_real64,
dimension(n) :: xk
137 sll_real64,
dimension(n) :: wk
141 sll_real64 :: alpha(0:n - 1), beta(0:n - 1)
142 sll_real64 :: de(n), da(n), db(n)
149 beta(k) = real(k**2, f64)/real((2*k + 1)*(2*k - 1), f64)
157 call dlob(n - 2, alpha, beta, -1._f64, 1._f64, xk, wk, err, de, da, db)
165 if (
present(a) .and.
present(b))
then
180 sll_int32,
intent(in) :: n
181 sll_real64,
intent(in),
optional :: a
182 sll_real64,
intent(in),
optional :: b
183 sll_real64,
dimension(n) :: xk
184 sll_real64,
dimension(n) :: wk
187 sll_real64 :: alpha(0:n - 1), beta(0:n - 1)
188 sll_real64 :: de(n), da(n), db(n)
196 beta(k) = real(k**2, f64)/real((2*k + 1)*(2*k - 1), f64)
204 call dlob(n - 2, alpha, beta, -1._f64, 1._f64, xk, wk, err, de, da, db)
206 if (
present(a) .and.
present(b))
then
218 sll_int32,
intent(in) :: n
219 sll_real64,
optional :: y(n)
221 sll_int32 :: i, j, l, m
223 sll_real64 :: d(n, n)
238 prod = prod*(x(i) - x(m))/(x(j) - x(m))
241 prod = prod*(x(i) - x(m))/(x(j) - x(m))
244 prod = prod*(x(i) - x(m))/(x(j) - x(m))
246 prod = prod/(x(j) - x(l))
247 d(i, j) = d(i, j) + prod
252 prod = prod*(x(i) - x(m))/(x(j) - x(m))
255 prod = prod*(x(i) - x(m))/(x(j) - x(m))
258 prod = prod*(x(i) - x(m))/(x(j) - x(m))
260 prod = prod/(x(j) - x(l))
261 d(i, j) = d(i, j) + prod
312 subroutine dlob(n, dalpha, dbeta, dleft, dright, dzero, dweigh, ierr, de, da, db)
314 sll_int32 :: n, ierr, k, np1, np2
315 sll_real64 :: dleft, dright, depsma, dp0l, dp0r, dp1l, dp1r, dpm1l
316 sll_real64 :: dpm1r, ddet, dalpha(*), dbeta(*), dzero(*), dweigh(*), de(*), da(*), db(*)
318 depsma = epsilon(1.0_f64)
334 dp1l = (dleft - da(k))*dp0l - db(k)*dpm1l
335 dp1r = (dright - da(k))*dp0r - db(k)*dpm1r
337 ddet = dp1l*dp0r - dp1r*dp0l
338 da(np2) = (dleft*dp1l*dp0r - dright*dp1r*dp0l)/ddet
339 db(np2) = (dright - dleft)*dp1l*dp1r/ddet
340 call dgauss(np2, da, db, depsma, dzero, dweigh, ierr, de)
388 subroutine dgauss(n, dalpha, dbeta, deps, dzero, dweigh, ierr, de)
389 sll_int32 :: n, ierr, i, ii, j, k, l, m, mml
391 sll_real64 :: dp, dg, dr, ds, dc, df, db
392 sll_real64 :: dalpha(n), dbeta(n), dzero(n), dweigh(n), de(n)
400 if (dbeta(1) .lt. 0.0_f64)
then
410 if (dbeta(k) .lt. 0.0_f64)
then
414 de(k - 1) = sqrt(dbeta(k))
420 if (m .eq. n)
goto 120
421 if (abs(de(m)) .le. deps*(abs(dzero(m)) + abs(dzero(m + 1))))
goto 120
424 if (m .eq. l)
goto 240
425 if (j .eq. 30)
goto 400
427 dg = (dzero(l + 1) - dp)/(2.0_f64*de(l))
428 dr = sqrt(dg*dg + 1.0_f64)
429 dg = dzero(m) - dp + de(l)/(dg + sign(dr, dg))
438 if (abs(df) .lt. abs(dg))
goto 150
440 dr = sqrt(dc*dc + 1.0_f64)
446 dr = sqrt(ds*ds + 1.0_f64)
450 160 dg = dzero(i + 1) - dp
451 dr = (dzero(i) - dg)*ds + 2.0_f64*dc*db
453 dzero(i + 1) = dg + dp
456 dweigh(i + 1) = ds*dweigh(i) + dc*df
457 dweigh(i) = dc*dweigh(i) - ds*df
459 dzero(l) = dzero(l) - dp
469 if (dzero(j) .ge. dp)
goto 260
473 if (k .eq. i)
goto 300
477 dweigh(i) = dweigh(k)
481 dweigh(k) = dbeta(1)*dweigh(k)*dweigh(k)
Integrate numerically with Gauss-Lobatto formula.
Gauss-Lobatto integration.
function, public sll_f_gauss_lobatto_derivative_matrix(n, y)
Construction of the derivative matrix for Gauss-Lobatto, The matrix must be already allocated of size...
subroutine dgauss(n, dalpha, dbeta, deps, dzero, dweigh, ierr, de)
Given n and a measure dlambda, this routine generates the n-point Gaussian quadrature formula.
real(kind=f64) function, dimension(n), public sll_f_gauss_lobatto_points(n, a, b)
Returns a 1d array of size (n) containing gauss-lobatto points in the interval [a,...
real(kind=f64) function, dimension(n), public sll_f_gauss_lobatto_weights(n, a, b)
Returns a 1d array of size (n) containing gauss-lobatto weights in the interval [a,...
real(kind=f64) function, dimension(2, n), public sll_f_gauss_lobatto_points_and_weights(n, a, b)
Returns a 2d array of size (2,n) containing gauss-lobatto points and weights in the interval [a,...
subroutine dlob(n, dalpha, dbeta, dleft, dright, dzero, dweigh, ierr, de, da, db)
This comes from http://dl.acm.org, Algorithme 726 : ORTHPOL, appendices and supplements To use those ...
real(kind=f64) function gauss_lobatto_integral_1d(f, a, b, n)
Gauss-Lobatto Quadrature.
Module to select the kind parameter.