Skip to main content

LagrangeCoeff_Triangle

Returns the coefficients for Lagrange polynomial.

This function returns the coefficient of basis functions.

pn(x,y)=a=0b=0ca,bxaybp_{n}(x,y) = \sum_{a=0}\sum_{b=0}{c_{a,b}x^{a}y^{b}}

This routine returns ca,bc_{a,b}.

note

There are four interfaces for this function.

Interface 1

INTERFACE
MODULE FUNCTION LagrangeCoeff_Triangle(order, i, xij) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: order
!! order of polynomial
INTEGER(I4B), INTENT(IN) :: i
!! ith coefficients for lagrange polynomial
REAL(DFP), INTENT(IN) :: xij(:, :)
!! points in xij format, size(xij,2)
REAL(DFP) :: ans(SIZE(xij, 2))
!! coefficients
END FUNCTION LagrangeCoeff_Triangle
END INTERFACE
order

Order of Lagrange polynomial.

i

ith Lagrnage polynomial.

xij

Points in xij format, size(xij,2) denotes the number of points. These are actually the interpolation points.

note
  • This subroutine will use the monomial basis functions.
  • Internally we compute the Vandermonde matrix and then solve it to get the coefficients.

Interface 2

INTERFACE
MODULE FUNCTION LagrangeCoeff_Triangle(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
!! 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(SIZE(v, 1))
!! coefficients of ith Lagrange polynomial
END FUNCTION LagrangeCoeff_Triangle
END INTERFACE
order

order of Lagrange polynomial, it should be equal to the SIZE(v,2)-1.

i

ith Lagrange polynomial.

v

Vandermonde matrix, The size should be at least (order+1,order+1).

Interface 3

INTERFACE
MODULE FUNCTION LagrangeCoeff_Triangle(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 lagrange polynomial
REAL(DFP), INTENT(INOUT) :: v(:, :)
!! LU decomposition of vandermonde matrix
INTEGER(I4B), INTENT(IN) :: ipiv(:)
!! inverse pivoting mapping, it is returned from LU decomposition
REAL(DFP) :: ans(SIZE(v, 1))
!! coefficients of ith Lagrange polynomial
END FUNCTION LagrangeCoeff_Triangle
END INTERFACE

Interface 4

INTERFACE
MODULE FUNCTION LagrangeCoeff_Triangle(order, xij, basisType, refTriangle) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: order
!! order of polynomial
REAL(DFP), INTENT(IN) :: xij(:, :)
!! points in xij format, size(xij,2)
INTEGER(I4B), OPTIONAL, INTENT(IN) :: basisType
!! Monomials
!! Jacobi
!! Heirarchical
CHARACTER(*), OPTIONAL, INTENT(IN) :: refTriangle
REAL(DFP) :: ans(SIZE(xij, 2), SIZE(xij, 2))
!! coefficients
END FUNCTION LagrangeCoeff_Triangle
END INTERFACE

This is the master function, which allows us to specify the basis type and reference triangle.

basisType
  • Here, basis type is the type of basis functions we want to use for contructing the Lagrange polynomials. It can take following values:
    • Monomials (default)
    • Jacobi, Orthogonal, Legendre, Lobatto, Ultraspherical (in this case we call Dubiner functions)
    • Heirarchical
ans

It represents the coefficients of the Lagrange polynomial. ans(:, i) denotes the coefficients of ith Lagrange polynomial.