gjp_common Module Reference

This module provides utility functions for computing Jacobi matrices and zeroth moments. More...

Functions/Subroutines

type(gjp_sparse_matrix) function jacobi_matrix (n, alpha, beta)
 Computes the Jacobi matrix for given parameters. More...
 
real(dp) function jacobi_zeroeth_moment (alpha, beta)
 Computes the zeroth moment for Jacobi polynomials. More...
 

Detailed Description

This module provides utility functions for computing Jacobi matrices and zeroth moments.

This module contains essential functions for working with Jacobi polynomials. These functions are particularly useful for various numerical methods that utilize Jacobi polynomials. The module provides a function for generating a Jacobi matrix and another for calculating the zeroth moment of Jacobi polynomials.

Functions included are:

  • jacobi_matrix: Generates a Jacobi matrix based on given alpha and beta parameters.
  • jacobi_zeroeth_moment: Calculates the zeroth moment of Jacobi polynomials.

Function/Subroutine Documentation

◆ jacobi_matrix()

type(gjp_sparse_matrix) function gjp_common::jacobi_matrix ( integer, intent(in)  n,
real(dp), intent(in)  alpha,
real(dp), intent(in)  beta 
)

Computes the Jacobi matrix for given parameters.

The Jacobi matrix is computed as: [ J_{i,j} = \begin{cases} \alpha & \text{if } i = j \ \beta & \text{if } |i-j| = 1 \ 0 & \text{otherwise} \end{cases} ]

Parameters
[in]nSize of the matrix, number of points
[in]alphaparameter for Jacobi polynomials
[in]betaparameter for Jacobi polynomials
Returns
A gjp_sparse_matrix representing the Jacobi matrix

Definition at line 49 of file gjp_common.f90.

50  integer, intent(in) :: n ! Size of the matrix, number of points
51  real(dp), intent(in) :: alpha, beta
52  type(gjp_sparse_matrix) :: jacmat
53  integer :: idx
54  real(dp) :: ab, abi, a2b2
55 
56  allocate (jacmat%diagonal(n))
57  allocate (jacmat%off_diagonal(n - 1))
58 
59  ab = alpha + beta
60  abi = 2.0_dp + ab
61  jacmat%diagonal(1) = (beta - alpha) / abi
62  jacmat%off_diagonal(1) = 4.0_dp * (1.0_dp + alpha) * (1.0_dp + beta) &
63  / ((abi + 1.0_dp) * abi * abi)
64  a2b2 = beta * beta - alpha * alpha
65  do idx = 2, n
66  abi = 2.0_dp * idx + ab
67  jacmat%diagonal(idx) = a2b2 / ((abi - 2.0_dp) * abi)
68  abi = abi**2
69  if (idx < n) then
70  jacmat%off_diagonal(idx) = 4.0_dp * idx * (idx + alpha) * (idx + beta) &
71  * (idx + ab) / ((abi - 1.0_dp) * abi)
72  end if
73  end do
74  jacmat%off_diagonal(1:n - 1) = sqrt(jacmat%off_diagonal(1:n - 1))

◆ jacobi_zeroeth_moment()

real(dp) function gjp_common::jacobi_zeroeth_moment ( real(dp), intent(in)  alpha,
real(dp), intent(in)  beta 
)

Computes the zeroth moment for Jacobi polynomials.

The zeroth moment is computed using the formula: [ \text{zmom} = 2^{(\alpha + \beta + 1)} \frac{\Gamma(\alpha + 1) \Gamma(\beta + 1)}{\Gamma(2 + \alpha + \beta)} ] Where (\Gamma) is the gamma function.

Parameters
[in]alphaparameter for Jacobi polynomials
[in]betaparameter for Jacobi polynomials
Returns
The zeroth moment value
Note
The zeroth moment should always be positive

Definition at line 89 of file gjp_common.f90.

90  real(dp), intent(in) :: alpha, beta
91  real(dp) :: zmom
92  real(dp) :: ab, abi
93 
94  ab = alpha + beta
95  abi = 2.0_dp + ab
96 
97  zmom = 2.0_dp**(alpha + beta + 1.0_dp) * exp(log_gamma(alpha + 1.0_dp) &
98  + log_gamma(beta + 1.0_dp) - log_gamma(abi))
99 
100  if (zmom <= 0.0_dp) then
101  error stop "Zeroth moment is not positive but should be"
102  end if