# ply_lagrange_module Module

Lagrange polynomial representation.

Lagrange polynomial series by the values at given nodes. The nodes to be used are to be given in form of ply_nodeset_coords.

## Derived Types

### type, public :: ply_lagrange_type

#### Components

TypeVisibilityAttributesNameInitial
integer, private :: nPoints

Number of points to represent the Lagrange polynomials

real(kind=rk), private, allocatable:: coords(:)

Coordinates of the points where the nodes are to be found.

real(kind=rk), private, allocatable:: values(:)

Values of the function at all coords.

## Functions

### public function ply_lagrange_define(nPoints, nodeset, values) result(me)

Define a new polynomial in the Lagrange basis.

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: nPoints

Number of points to define the polynomial.

procedure(ply_nodeset_coords) :: nodeset

The set of nodes where the function assumes the given values.

real(kind=rk), intent(in) :: values(nPoints)

Function values at all nPoints of the nodeset.

#### Return Value type(ply_lagrange_type)

The newly created Lagrange series describing the polynomial function.

### public function ply_lagrange_eval(me, x) result(f)

Evaluate a polynomial in the Lagrange basis at some point x.

#### Arguments

TypeIntentOptionalAttributesName
type(ply_lagrange_type), intent(in) :: me

The polynomial in Lagrange basis to evaluate at point x.

real(kind=rk), intent(in) :: x

Coordinate at which the function is to be evaluated.

#### Return Value real(kind=rk)

Value of the polynomial at coordinate x.

### public function ply_lagrange_mode_at(me, mode, x) result(f)

Evaluate the given Lagrangian mode (which is 1 at coord(mode) and 0 in all other points) at a given point x.

#### Arguments

TypeIntentOptionalAttributesName
type(ply_lagrange_type), intent(in) :: me

The polynomial in Lagrange basis.

integer, intent(in) :: mode

Mode to evaluate at x.

Here mode identifies the polynomial that is 1 in me%coord(mode) and 0 in all other nodes.

real(kind=rk), intent(in) :: x

Coordinate at which the mode is to be evaluated.

#### Return Value real(kind=rk)

Value of the polynomial at coordinate x.

### public function ply_lagrange_1D(me, points) result(pointval)

#### Arguments

TypeIntentOptionalAttributesName
type(ply_lagrange_type), intent(in) :: me

Definition of the Lagrange polynomial basis to evaluate at points.

real(kind=rk), intent(in) :: points(:)

List of points at which the polynomials are to be evaluated.

#### Return Value real(kind=rk)(me%nPoints,size(points))

Resulting Lagrange values at all points.

First dimension holds the Lagrange modes, second dimension the points.