BarycentricWeights Subroutine

public subroutine BarycentricWeights(N_in, xGP, wBary)

Computes barycentric (interpolation) weights for interpolation polynomial given by set of nodes. (Algorithm 30, Kopriva book)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: N_in

polynomial degree

real(kind=wp), intent(in) :: xGP(0:N_in)

Gauss point positions for the reference interval [-1,1]

real(kind=wp), intent(out) :: wBary(0:N_in)

barycentric weights


Source Code

SUBROUTINE BarycentricWeights(N_in,xGP,wBary)
IMPLICIT NONE
!----------------------------------------------------------------------------------------------------------------------------------
! INPUT/OUTPUT VARIABLES
INTEGER,INTENT(IN) :: N_in               !! polynomial degree
REAL(wp),INTENT(IN)    :: xGP(0:N_in)        !! Gauss point positions for the reference interval [-1,1]
REAL(wp),INTENT(OUT)   :: wBary(0:N_in)      !! barycentric weights
!----------------------------------------------------------------------------------------------------------------------------------
! LOCAL VARIABLES
INTEGER            :: iGP,jGP
!==================================================================================================================================
wBary(:)=1.0_wp
DO iGP=1,N_in
  DO jGP=0,iGP-1
    wBary(jGP)=wBary(jGP)*(xGP(jGP)-xGP(iGP))
    wBary(iGP)=wBary(iGP)*(xGP(iGP)-xGP(jGP))
  END DO ! jGP
END DO ! iGP
wBary(:)=1.0_wp/wBary(:)
END SUBROUTINE BarycentricWeights