gjp_rec Module Reference

This is derived from the recurrence relations in chebfun. More...

Functions/Subroutines

subroutine gauss_jacobi_rec (npts, alpha, beta, x, wts)
 
subroutine recurrence (npts, n2, alpha, beta, x, PP)
 
subroutine eval_jacobi_poly (x, npts, alpha, beta, P, Pp)
 

Detailed Description

This is derived from the recurrence relations in chebfun.

Function/Subroutine Documentation

◆ eval_jacobi_poly()

subroutine gjp_rec::eval_jacobi_poly ( real(dp), dimension(:), intent(in)  x,
integer, intent(in)  npts,
real(dp), intent(in)  alpha,
real(dp), intent(in)  beta,
real(dp), dimension(size(x)), intent(out)  P,
real(dp), dimension(size(x)), intent(out)  Pp 
)

Definition at line 91 of file gjp_rec.f90.

92  integer, intent(in) :: npts
93  real(dp), intent(in) :: alpha, beta
94  real(dp), intent(in) :: x(:)
95  real(dp), dimension(size(x)), intent(out) :: P, Pp
96  real(dp), dimension(size(x)) :: Pm1, Ppm1, Pa1, Ppa1
97  integer :: k, i
98  real(dp) :: A_val, B_val, C_val, D_val
99 
100  p = 0.5_dp * (alpha - beta + (alpha + beta + 2) * x)
101  pm1 = 1.0_dp
102  pp = 0.5_dp * (alpha + beta + 2)
103  ppm1 = 0.0_dp
104 
105  if (npts == 0) then
106  p = pm1
107  pp = ppm1
108  end if
109 
110  do k = 1, npts - 1
111  a_val = 2 * (k + 1) * (k + alpha + beta + 1) * (2 * k + alpha + beta)
112  b_val = (2 * k + alpha + beta + 1) * (alpha**2 - beta**2)
113  c_val = product([(2 * k + alpha + beta + i, i=0, 2)])
114  d_val = 2 * (k + alpha) * (k + beta) * (2 * k + alpha + beta + 2)
115 
116  pa1 = ((b_val + c_val * x) * p - d_val * pm1) / a_val
117  ppa1 = ((b_val + c_val * x) * pp + c_val * p - d_val * ppm1) / a_val
118 
119  pm1 = p
120  p = pa1
121  ppm1 = pp
122  pp = ppa1
123  end do

◆ gauss_jacobi_rec()

subroutine gjp_rec::gauss_jacobi_rec ( integer, intent(in)  npts,
real(dp), intent(in)  alpha,
real(dp), intent(in)  beta,
real(dp), dimension(npts), intent(out)  x,
real(dp), dimension(npts), intent(out)  wts 
)

Definition at line 35 of file gjp_rec.f90.

36  integer, intent(in) :: npts
37  real(dp), intent(in) :: alpha, beta
38  real(dp), intent(out) :: x(npts), wts(npts)
39  real(dp), dimension(ceiling(npts/2._dp)) :: x1, ders1
40  real(dp), dimension(npts/2) :: x2, ders2
41  real(dp) :: ders(npts), C
42  integer :: idx
43  call recurrence(npts, ceiling(npts / 2._dp), alpha, beta, x1, ders1)
44  call recurrence(npts, npts / 2, beta, alpha, x2, ders2)
45  do idx = 1, npts / 2
46  x(idx) = -x2(npts / 2 - idx + 1)
47  ders(idx) = ders2(npts / 2 - idx + 1)
48  end do
49  do idx = 1, ceiling(npts / 2._dp)
50  x(npts / 2 + idx) = x1(idx)
51  ders(npts / 2 + idx) = ders1(idx)
52  end do
53  wts = 1.0_dp / ((1.0_dp - x**2) * ders**2)
54  c = 2**(alpha + beta + 1) * exp(log_gamma(npts + alpha + 1) - &
55  log_gamma(npts + alpha + beta + 1) + &
56  log_gamma(npts + beta + 1) - log_gamma(npts + 1._dp))
57  wts = wts * c

◆ recurrence()

subroutine gjp_rec::recurrence ( integer, intent(in)  npts,
integer, intent(in)  n2,
real(dp), intent(in)  alpha,
real(dp), intent(in)  beta,
real(dp), dimension(n2), intent(out)  x,
real(dp), dimension(n2), intent(out)  PP 
)

Definition at line 60 of file gjp_rec.f90.

61  integer, intent(in) :: npts, n2
62  real(dp), intent(in) :: alpha, beta
63  real(dp), intent(out) :: x(n2), PP(n2)
64  real(dp) :: dx(n2), P(n2)
65  integer :: r(n2), l, i
66  real(dp) :: C, T
67 
68  do i = 1, n2
69  r(i) = n2 - i + 1
70  end do
71 
72  do i = 1, n2
73  c = (2 * r(i) + alpha - 0.5_dp) * pi / (2 * npts + alpha + beta + 1)
74  t = c + 1 / (2 * npts + alpha + beta + 1)**2 * ((0.25_dp - alpha**2) / tan(0.5_dp * c) - (0.25_dp - beta**2) * tan(0.5_dp * c))
75  x(i) = cos(t)
76  end do
77 
78  dx = 1.0_dp
79  l = 0
80 
81  do while (maxval(abs(dx)) > sqrt(epsilon(1.0_dp)) / 1000 .and. l < 10)
82  l = l + 1
83  call eval_jacobi_poly(x, npts, alpha, beta, p, pp)
84  dx = -p / pp
85  x = x + dx
86  end do
87 
88  call eval_jacobi_poly(x, npts, alpha, beta, p, pp)