GaussJacobiQuad.f90
Go to the documentation of this file.
1 ! BEGIN_HEADER
2 ! -----------------------------------------------------------------------------
3 ! Gauss-Jacobi Quadrature Implementation
4 ! Authors: Rohit Goswami <rgoswami[at]ieee.org>
5 ! Source: GaussJacobiQuad Library
6 ! License: MIT
7 ! GitHub Repository: https://github.com/HaoZeke/GaussJacobiQuad
8 ! Date: 2023-08-28
9 ! Commit: c442f77
10 ! -----------------------------------------------------------------------------
11 ! This code is part of the GaussJacobiQuad library, providing an efficient
12 ! implementation for Gauss-Jacobi quadrature nodes and weights computation.
13 ! -----------------------------------------------------------------------------
14 ! To cite this software:
15 ! Rohit Goswami (2023). HaoZeke/GaussJacobiQuad: v0.1.0.
16 ! Zenodo: https://doi.org/10.5281/ZENODO.8285112
17 ! ---------------------------------------------------------------------
18 ! END_HEADER
20 !
21 !! @details This module implements the Gauss-Jacobi quadrature method for numerical integration.
22 !! It provides a subroutine for obtaining the weights and nodes, which dispatches to multiple implementations
23 !! based on the method provided. Available methods include "rec".
25 use gjp_rec, only: gauss_jacobi_rec
26 use gjp_gw, only: gauss_jacobi_gw
28 use gjp_types, only: dp
29 implicit none
30 contains
31 
50 subroutine gauss_jacobi(npts, alpha, beta, x, wts, method)
51  integer, intent(in) :: npts
52  real(dp), intent(in) :: alpha, beta
53  real(dp), intent(out) :: x(npts), wts(npts)
54  character(len=:), allocatable, intent(in) :: method
55 
56  if (npts <= 0) then
57  error stop "Number of points must be positive"
58  end if
59 
60  if (alpha <= -1.0_dp) then
61  error stop "alpha must be greater than -1"
62  end if
63 
64  if (beta <= -1.0_dp) then
65 
66  error stop "beta must be greater than -1"
67  end if
68 
69  select case (trim(method))
70  case ("rec") ! Fails at high beta
71  call gauss_jacobi_rec(npts, alpha, beta, x, wts)
72  case ("gw") ! Accurate for high beta
73  call gauss_jacobi_gw(npts, alpha, beta, x, wts)
74  case ("algo665")
75  call gauss_jacobi_algo665(npts, alpha, beta, x, wts)
76  case default
77  print*,"Error: Unknown method specified:", method
78  print*,"Supported methods: 'rec', 'gw', 'algo665'"
79  error stop
80  end select
81 end subroutine gauss_jacobi
82 
83 end module gaussjacobiquad
Overall driver for Gauss-Jacobi quadrature.
subroutine gauss_jacobi(npts, alpha, beta, x, wts, method)
Compute the Gauss-Jacobi quadrature nodes and weights.
This module provides routines for numerical integration using Gauss-Jacobi quadrature.
Definition: gjp_algo665.f90:29
subroutine gauss_jacobi_algo665(npts, alpha, beta, x, wts)
Computes the zeros and weights for Gauss-Jacobi quadrature.
Definition: gjp_algo665.f90:61
Module for computing Gauss-Jacobi quadrature nodes and weights using the Golub-Welsch (GW) method.
Definition: gjp_gw.f90:28
subroutine gauss_jacobi_gw(npts, alpha, beta, x, wts)
Computes the zeros and weights for Gauss-Jacobi quadrature.
Definition: gjp_gw.f90:60
This is derived from the recurrence relations in chebfun.
Definition: gjp_rec.f90:28
subroutine gauss_jacobi_rec(npts, alpha, beta, x, wts)
Definition: gjp_rec.f90:36
Module for defining types and precision levels for Gauss-Jacobi Polynomial (GJP) calculations.
Definition: gjp_types.f90:33
integer, parameter, public dp
Define various kinds for real numbers.
Definition: gjp_types.f90:39