LagrangeCoeff_Line
Interface 1
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE FUNCTION LagrangeCoeff_Line(order, i, xij) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: order
!! order of polynomial, it should be SIZE(xij,2)-1
INTEGER(I4B), INTENT(IN) :: i
!! ith coefficients for lagrange polynomial
REAL(DFP), INTENT(IN) :: xij(:, :)
!! points in xij format, size(xij,2) = order+1
REAL(DFP) :: ans(order + 1)
!! coefficients
END FUNCTION LagrangeCoeff_Line
END INTERFACE
order
order of polynomial space.
i
ith polynomial
xij
- Interpolation points
- SIZE(xij,1) is equal to 1
- SIZE(xij,2) is equal to order+1
ans
order+1
coefficients of ith Lagrange polynomial.
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: ")
ans = LagrangeCoeff_Line(order, 1, xij)
call display(ans, "ans: ")
end program main
ans:
--------
1.0000
-8.3333
23.3333
-26.6667
10.6667
Interface 2
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE FUNCTION LagrangeCoeff_Line(order, i, v, isVandermonde) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: order
!! order of polynomial, it should be SIZE(v,2)-1
INTEGER(I4B), INTENT(IN) :: i
!! coefficient for ith lagrange polynomial
REAL(DFP), INTENT(IN) :: v(:, :)
!! vandermonde matrix size should be (order+1,order+1)
LOGICAL(LGT), INTENT(IN) :: isVandermonde
!! This is just to resolve interface issue
REAL(DFP) :: ans(order + 1)
!! coefficients
END FUNCTION LagrangeCoeff_Line
END INTERFACE
order
order of polynomial space.
i
ith polynomial
v
- Vandermonde matrix
- The jth col of v denotes the values of basis function on interpolation points.
- The ith row of v denotes the values of all basis function on ith interpolation points.
ans
order+1
coefficients of ith Lagrange polynomial.
Interface 3
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE FUNCTION LagrangeCoeff_Line(order, i, v, ipiv) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: order
!! order of polynomial, it should be SIZE(x,2)-1
INTEGER(I4B), INTENT(IN) :: i
!! ith coefficients for lagrange polynomial
REAL(DFP), INTENT(INOUT) :: v(:, :)
!! LU decomposition of vandermonde matrix
INTEGER(I4B), INTENT(IN) :: ipiv(:)
!! inverse pivoting mapping, compes from LU decomposition
REAL(DFP) :: ans(order + 1)
!! coefficients
END FUNCTION LagrangeCoeff_Line
END INTERFACE
order
order of polynomial space.
i
ith polynomial
v
- LU decomposition of Vandermonde matrix
- The jth col of v denotes the values of basis function on interpolation points.
- The ith row of v denotes the values of all basis function on ith interpolation points.
ipiv
ipiv
is returned by Lapack when performing LU
decomposition.
ans
order+1
coefficients of ith Lagrange polynomial.
Interface 4
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE FUNCTION LagrangeCoeff_Line(order, xij) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: order
!! order of polynomial, it should be SIZE(xij,2)-1
REAL(DFP), INTENT(IN) :: xij(:, :)
!! points in xij format, size(xij,2) = order+1
REAL(DFP) :: ans(order + 1, order + 1)
!! coefficients
!! jth column of ans corresponds to the coeff of lagrange polynomial
!! at the jth point
END FUNCTION LagrangeCoeff_Line
END INTERFACE
xij
Interpolation points. SIZE(xij, 1) is 1. SIZE(xij, 2) should be equal to order+1.
order
order denotes the order of polynomial space.
ans
The jth col of ans
denotes the order+1
coefficents of jth polynomial.
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 = LagrangeCoeff_Line(order, xij)
call display(coeff, "ans: ")
end program main
ans:
------------------------------------------------
1.000 -0.000 0.000 0.000 0.000
-8.333 -1.000 16.000 -12.000 5.333
23.333 7.333 -69.333 76.000 -37.333
-26.667 -16.000 96.000 -128.000 74.667
10.667 10.667 -42.667 64.000 -42.667
Interace 5
- ܀ Interface
- ️܀ See example
- Example 2
- Example 3
- ↢
INTERFACE LagrangeCoeff_Line
MODULE FUNCTION LagrangeCoeff_Line5(order, xij, orthopol, alpha, &
& beta, lambda) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: order
!! order of polynomial, it should be SIZE(xij,2)-1
REAL(DFP), INTENT(IN) :: xij(:, :)
!! points in xij format, size(xij,2) = order+1
INTEGER(I4B), 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, order + 1)
!! coefficients
!! jth column of ans corresponds to the coeff of lagrange polynomial
!! at the jth point
END FUNCTION LagrangeCoeff_Line5
END INTERFACE LagrangeCoeff_Line
xij
Interpolation points. SIZE(xij, 1) is 1. SIZE(xij, 2) should be equal to order+1.
order
order denotes the order of polynomial space.
orthopol
Currently, we can specify following types of orthogonal polynomials:
- Jacobi
- Ultraspherical
- Legendre
- Chebyshev
- Lobatto
- UnscaledLobatto
alpha, beta
alpha and beta are parameters of Jacobi Polynomials. They should be present when orthopol
is equal to Jacobi
lambda
lambda
is parameter for Ultraspherical polynomials. They should be present when orthopol
is equal to the Ultraspherical
ans
The jth col of ans
denotes the order+1
coefficents of jth polynomial.
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, orthopol
!! "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: ")
orthopol= Monomial
coeff = LagrangeCoeff_Line(order=order, xij=xij, orthopol=orthopol)
call display(coeff, "ans: ")
end program main
ans:
------------------------------------------------
1.000 -0.000 0.000 0.000 0.000
-8.333 -1.000 16.000 -12.000 5.333
23.333 7.333 -69.333 76.000 -37.333
-26.667 -16.000 96.000 -128.000 74.667
10.667 10.667 -42.667 64.000 -42.667
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, orthopol
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: ")
orthopol= Legendre
coeff = LagrangeCoeff_Line(order=order, xij=xij, orthopol=orthopol)
call display(coeff, "ans: ")
end program main
ans:
------------------------------------------------
10.9111 4.5778 -31.6444 38.1333 -20.9778
-24.3333 -10.6000 73.6000 -88.8000 50.1333
21.6508 10.9841 -70.6032 87.2381 -49.2698
-10.6667 -6.4000 38.4000 -51.2000 29.8667
2.4381 2.4381 -9.7524 14.6286 -9.7524
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, orthopol
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: ")
orthopol= Chebyshev
coeff = LagrangeCoeff_Line(order=order, xij=xij, orthopol=orthopol)
call display(coeff, "ans: ")
end program main
ans:
------------------------------------------------
16.667 7.667 -50.667 62.000 -34.667
-28.333 -13.000 88.000 -108.000 61.333
17.000 9.000 -56.000 70.000 -40.000
-6.667 -4.000 24.000 -32.000 18.667
1.333 1.333 -5.333 8.000 -5.333