LagrangeCoeff
Returns the coefficients of lagrange polynomial.
The Nth order lagrange polynomial in 1D can be described as:
This function returns coefficients
Interface 1
- ܀ Interface
- ️܀ See example
- Example 2
- Example 3
- ↢
INTERFACE
MODULE FUNCTION LagrangeCoeff(order, elemType, i, xij) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: order
!! order of polynomial
INTEGER(I4B), INTENT(IN) :: elemType
!! element type
INTEGER(I4B), INTENT(IN) :: i
!! ith coefficients for lagrange polynomial
REAL(DFP), INTENT(IN) :: xij(:, :)
!! points in xij format
REAL(DFP), ALLOCATABLE :: ans(:)
!! coefficients
END FUNCTION LagrangeCoeff
END INTERFACE
PROGRAM main
use easifemBase
implicit none
real(dfp), allocatable :: coeff(:), xij(:,:), ans(:)
integer(i4b) :: order, elemType, i
real(dfp), parameter :: tol=1.0E-10
Line LagrangeCoeff
i = 1; elemType=Line; order=1
xij = zeros(1, 2, 1.0)
xij(1, : ) = [0,1]
coeff = LagrangeCoeff(order=order, elemType=elemType, i=i, xij=xij)
ans = [1.0, -1.0]
call ok( all(softeq(coeff, ans, tol)), "")
i = 2
coeff = LagrangeCoeff(order=order, elemType=elemType, i=i, xij=xij)
ans=[0.0, 1.0]
call ok( all(softeq(coeff, ans, tol)), "")
END PROGRAM main
Following methods are tested.
- LagrangeCoeff
PROGRAM main
use easifemBase
implicit none
real(dfp), allocatable :: coeff(:), xij(:,:), ans(:)
integer(i4b) :: order, elemType, i
real(dfp), parameter :: tol=1.0E-10
Triangle LagrangeCoeff
i = 1; elemType=Triangle; order=1
xij = EquidistancePoint(order, elemType)
coeff = LagrangeCoeff(order=order, elemType=elemType, i=i, xij=xij)
ans = [1.0, -1.0, -1.0]
!call display(coeff, "coeff=")
call ok( all(softeq(coeff, ans, tol)), "")
i = 2
coeff = LagrangeCoeff(order=order, elemType=elemType, i=i, xij=xij)
ans = [0.0, 1.0, 0.0]
!call display(coeff, "coeff=")
call ok( all(softeq(coeff, ans, tol)), "")
i = 3
coeff = LagrangeCoeff(order=order, elemType=elemType, i=i, xij=xij)
ans = [0.0, 0.0, 1.0]
!call display(coeff, "coeff=")
call ok( all(softeq(coeff, ans, tol)), "")
END PROGRAM main
Following methods are tested.
- LagrangeCoeff
PROGRAM main
use easifemBase
implicit none
real(dfp), allocatable :: coeff(:), xij(:,:), ans(:)
integer(i4b) :: order, elemType, i
real(dfp), parameter :: tol=1.0E-10
Quadrangle LagrangeCoeff
i = 1; elemType=Quadrangle; order=1
xij = EquidistancePoint(order, elemType)
coeff = LagrangeCoeff(order=order, elemType=elemType, i=i, xij=xij)
ans = [1.0, -1.0, -1.0, 1.0]*0.25
!call display(coeff, "coeff=")
call ok( all(softeq(coeff, ans, tol)), "")
i = 2
coeff = LagrangeCoeff(order=order, elemType=elemType, i=i, xij=xij)
ans = [1.0, 1.0, -1.0, -1.0]*0.25
!call display(coeff, "coeff=")
call ok( all(softeq(coeff, ans, tol)), "")
i = 3
coeff = LagrangeCoeff(order=order, elemType=elemType, i=i, xij=xij)
ans = [1.0, 1.0, 1.0, 1.0]*0.25
!call display(coeff, "coeff=")
call ok( all(softeq(coeff, ans, tol)), "")
END PROGRAM main