LagrangeEvalAll_Line
Evaluate Lagrangepolynomials at single point or several points.
Interface 1
- ܀ Interface
 - ️܀ See example
 - Example 2
 - ↢
 
INTERFACE LagrangeEvalAll_Line
  MODULE FUNCTION LagrangeEvalAll_Line1(order, x, xij, coeff, firstCall, &
    & orthopol, alpha, beta, lambda) &
    & RESULT(ans)
    INTEGER(I4B), INTENT(IN) :: order
    !! order of Lagrange polynomials
    REAL(DFP), INTENT(IN) :: x
    !! point of evaluation
    REAL(DFP), OPTIONAL, INTENT(INOUT) :: xij(1, order + 1)
    !! interpolation points
    REAL(DFP), OPTIONAL, INTENT(INOUT) :: coeff(order + 1, order + 1)
    !! coefficient of Lagrange polynomials
    LOGICAL(LGT), OPTIONAL :: firstCall
    !! If firstCall is true, then coeff will be made
    !! If firstCall is False, then coeff will be used
    !! Default value of firstCall is True
    INTEGER(I4B), OPTIONAL, INTENT(IN) :: orthopol
    !! Monomial
    !! Jacobi
    !! Legendre
    !! Chebyshev
    !! Lobatto
    !! UnscaledLobatto
    REAL(DFP), OPTIONAL, INTENT(IN) :: alpha
    !! Jacobi polynomial parameter
    REAL(DFP), OPTIONAL, INTENT(IN) :: beta
    !! Jacobi polynomial parameter
    REAL(DFP), OPTIONAL, INTENT(IN) :: lambda
    !! Ultraspherical parameter
    REAL(DFP) :: ans(order + 1)
    !! Value of n+1 Lagrange polynomials at point x
  END FUNCTION LagrangeEvalAll_Line1
END INTERFACE LagrangeEvalAll_Line
xPoint of evaluation.
xijInterpolation points. SIZE(xij, 1) is 1. SIZE(xij, 2) should be equal to order+1.
orderorder denotes the order of polynomial space.
orthopolCurrently, we can specify following types of orthogonal polynomials:
- Jacobi
 - Ultraspherical
 - Legendre
 - Chebyshev
 - Lobatto
 - UnscaledLobatto
 
alpha, betaalpha and beta are parameters of Jacobi Polynomials. They should be present when orthopol is equal to Jacobi
lambdalambda is parameter for Ultraspherical polynomials. They should be present when orthopol is equal to the Ultraspherical
ansans denotes the order+1 coefficents of ith polynomial.
coeff and firstCallcoeff denotes the coefficients of Lagrange polynomial. The jth col of coeff dentotes the coefficient of jth Lagrange polynomial.
- 
If
firstCallis true andcoeffis present, then this function will returncoeff, which can be used later. Note that computation ofcoeffinvolves inversion of a matrix. - 
If
firstCallis false andcoeffis present, then this function will usecoeff. 
program main
  use easifemBase
  implicit none
  integer(i4b) :: order
  real(dfp), parameter :: tol = 1.0E-10
  real(dfp), allocatable :: x(:), coeff(:,:), ans(:), xij(:,:)
  character( len = * ), parameter :: layout="VEFC" 
  integer(i4b) :: ipType
  !! "INCREASING"
  x = [0,1]
  order = 4_I4B
  iptype = Equidistance
  xij = reshape(InterpolationPoint_Line(order=order, iptype=iptype, layout=layout, xij=x), [1, order+1])
  call display(xij, "xij: ")
  coeff = zeros(order+1, order+1, 1.0_DFP)
  ans = LagrangeEvalAll_Line(order, xij(1,1), xij, coeff, firstCall=.true.)
  call ok(ans(1) .approxeq. 1.0_DFP, "tests(1):")
  call ok(all(ans(2:) .approxeq. 0.0_DFP), "tests(2):")
  ans = LagrangeEvalAll_Line(order, xij(1,2),  xij, coeff, firstCall=.false.)
  call ok(softeq( ans(1), 0.0_DFP, tol), "tests(3):")
  call ok(softeq( ans(2), 1.0_DFP, tol), "tests(4):")
  ans = LagrangeEvalAll_Line(order, xij(1,3),  xij, coeff, firstCall=.false.)
  call ok(all(softeq( ans(1:2), 0.0_DFP, tol)), "tests(5):")
  call ok(softeq( ans(3), 1.0_DFP, tol), "tests(6):")
  ans = LagrangeEvalAll_Line(order, xij(1,4),  xij, coeff, firstCall=.false.)
  call ok(all(softeq( ans(1:3), 0.0_DFP, tol)), "tests(7):")
  call ok(softeq( ans(4), 1.0_DFP, tol), "tests(8):")
end program main
program main
  use easifemBase
  implicit none
  integer(i4b) :: order
  real(dfp), parameter :: tol = 1.0E-10
  real(dfp), allocatable :: x(:), coeff(:,:), ans(:), xij(:,:)
  character( len = * ), parameter :: layout="VEFC" 
  integer(i4b) :: ipType
  !! "INCREASING"
  x = [0,1]
  order = 4_I4B
  iptype = GaussLegendreLobatto
  xij = reshape(InterpolationPoint_Line(order=order, iptype=iptype, layout=layout, xij=x), [1, order+1])
  call display(xij, "xij: ")
  coeff = zeros(order+1, order+1, 1.0_DFP)
  ans = LagrangeEvalAll_Line(order, xij(1,1), xij, coeff, firstCall=.true.)
  call ok(ans(1) .approxeq. 1.0_DFP, "tests(1):")
  call ok(all(ans(2:) .approxeq. 0.0_DFP), "tests(2):")
  ans = LagrangeEvalAll_Line(order, xij(1,2),  xij, coeff, firstCall=.false.)
  call ok(softeq( ans(1), 0.0_DFP, tol), "tests(3):")
  call ok(softeq( ans(2), 1.0_DFP, tol), "tests(4):")
  ans = LagrangeEvalAll_Line(order, xij(1,3),  xij, coeff, firstCall=.false.)
  call ok(all(softeq( ans(1:2), 0.0_DFP, tol)), "tests(5):")
  call ok(softeq( ans(3), 1.0_DFP, tol), "tests(6):")
  ans = LagrangeEvalAll_Line(order, xij(1,4),  xij, coeff, firstCall=.false.)
  call ok(all(softeq( ans(1:3), 0.0_DFP, tol)), "tests(7):")
  call ok(softeq( ans(4), 1.0_DFP, tol), "tests(8):")
end program main
Interface 2
- ܀ Interface
 - ️܀ See example
 - ↢
 
INTERFACE LagrangeEvalAll_Line
  MODULE FUNCTION LagrangeEvalAll_Line2(order, x, xij, coeff, firstCall, &
    & orthopol, alpha, beta, lambda) &
    & RESULT(ans)
    INTEGER(I4B), INTENT(IN) :: order
    !! order of Lagrange polynomials
    REAL(DFP), INTENT(IN) :: x(:)
    !! point of evaluation
    REAL(DFP), OPTIONAL, INTENT(INOUT) :: xij(1, order + 1)
    !! interpolation points
    REAL(DFP), OPTIONAL, INTENT(INOUT) :: coeff(order + 1, order + 1)
    !! coefficient of Lagrange polynomials
    LOGICAL(LGT), OPTIONAL :: firstCall
    !! If firstCall is true, then coeff will be made
    !! If firstCall is False, then coeff will be used
    !! Default value of firstCall is True
    INTEGER(I4B), OPTIONAL, INTENT(IN) :: orthopol
    !! Monomial
    !! Jacobi
    !! Legendre
    !! Chebyshev
    !! Lobatto
    !! UnscaledLobatto
    REAL(DFP), OPTIONAL, INTENT(IN) :: alpha
    !! Jacobi polynomial parameter
    REAL(DFP), OPTIONAL, INTENT(IN) :: beta
    !! Jacobi polynomial parameter
    REAL(DFP), OPTIONAL, INTENT(IN) :: lambda
    !! Ultraspherical parameter
    REAL(DFP) :: ans(SIZE(x), order + 1)
    !! Value of n+1 Lagrange polynomials at point x
    !! ans(:, j) is the value of jth polynomial at x points
    !! ans(i, :) is the value of all polynomials at x(i) point
  END FUNCTION LagrangeEvalAll_Line2
END INTERFACE LagrangeEvalAll_Line
xPoint of evaluation.
xijInterpolation points. SIZE(xij, 1) is 1. SIZE(xij, 2) should be equal to order+1.
orderorder denotes the order of polynomial space.
orthopolCurrently, we can specify following types of orthogonal polynomials:
- Jacobi
 - Ultraspherical
 - Legendre
 - Chebyshev
 - Lobatto
 - UnscaledLobatto
 
alpha, betaalpha and beta are parameters of Jacobi Polynomials. They should be present when orthopol is equal to Jacobi
lambdalambda is parameter for Ultraspherical polynomials. They should be present when orthopol is equal to the Ultraspherical
ansjth col of ans denotes the order+1 coefficents of jth polynomial.
coeff and firstCallcoeff denotes the coefficients of Lagrange polynomial. The jth col of coeff dentotes the coefficient of jth Lagrange polynomial.
- 
If
firstCallis true andcoeffis present, then this function will returncoeff, which can be used later. Note that computation ofcoeffinvolves inversion of a matrix. - 
If
firstCallis false andcoeffis present, then this function will usecoeff. 
program main
  use easifemBase
  implicit none
  integer(i4b) :: order
  real(dfp), parameter :: tol = 1.0E-10
  real(dfp), allocatable :: x(:), coeff(:,:), ans(:,:), xij(:,:)
  character( len = * ), parameter :: layout="VEFC" 
  integer(i4b) :: ipType
  !! "INCREASING"
  x = [0,1]
  order = 4_I4B
  iptype = GaussLegendreLobatto
  xij = reshape(InterpolationPoint_Line(order=order, iptype=iptype, layout=layout, xij=x), [1, order+1])
  call display(xij, "xij: ")
  coeff = zeros(order+1, order+1, 1.0_DFP)
  ans = LagrangeEvalAll_Line(order, xij(1,:), xij, coeff, firstCall=.true.)
  call ok(all(softeq(ans, eye(order+1, 1.0_DFP), tol ) ), "tests(1):")
end program main
1.00000   0.00000  -0.00000   0.00000  -0.00000
0.00000   1.00000   0.00000  -0.00000   0.00000
0.00000   0.00000   1.00000   0.00000  -0.00000
0.00000   0.00000  -0.00000   1.00000  -0.00000
0.00000  -0.00000   0.00000  -0.00000   1.00000