gjp_algo665.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
30 use gjp_types, only: dp, gjp_sparse_matrix
31 use gjp_imtqlx, only: imtqlx
33 implicit none
34 contains
35 
60 subroutine gauss_jacobi_algo665(npts, alpha, beta, x, wts)
61  integer, intent(in) :: npts
62  real(dp), intent(in) :: alpha, beta
63  real(dp), intent(out) :: x(npts), wts(npts)
64  real(dp) :: zeroeth_moment
65  type(gjp_sparse_matrix) :: jacobi_mat
66  real(dp) :: diagonal_elements(npts), &
67  off_diagonal_elements(npts - 1)
68 
69  jacobi_mat = jacobi_matrix(npts, alpha, beta)
70  zeroeth_moment = jacobi_zeroeth_moment(alpha, beta)
71 
72  ! Extract diagonal and off-diagonal elements
73  diagonal_elements = jacobi_mat%diagonal(1:npts)
74  off_diagonal_elements = jacobi_mat%off_diagonal(1:npts - 1)
75 
76  ! Initialize weights and knot points
77  wts = 0.0_dp
78  x = diagonal_elements
79  wts(1) = sqrt(zeroeth_moment)
80 
81  ! Diagonalize the Jacobi matrix using the modified implicitly shifted QL method.
82  call imtqlx(npts, x, off_diagonal_elements, wts)
83 
84  ! The weights are related to the squares of the the eigenvectors
85  wts = wts**2
86 
87 end subroutine gauss_jacobi_algo665
88 
89 end module gjp_algo665
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
This module provides utility functions for computing Jacobi matrices and zeroth moments.
Definition: gjp_common.f90:29
type(gjp_sparse_matrix) function jacobi_matrix(n, alpha, beta)
Computes the Jacobi matrix for given parameters.
Definition: gjp_common.f90:50
real(dp) function jacobi_zeroeth_moment(alpha, beta)
Computes the zeroth moment for Jacobi polynomials.
Definition: gjp_common.f90:90
subroutine imtqlx(mat_size, diag, off_diag, sol_vec)
Implicitly-shifted Modified QL factorization algorithm for symmetric tridiagonal matrices.
Definition: gjp_imtqlx.f90:44
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
Sparse representation of a Jacobi matrix.
Definition: gjp_types.f90:49