hermite_interpolator Derived Type

type, public, extends(base_interpolator) :: hermite_interpolator

Defines a type meant for performing Hermite-type interpolation. The interpolating polynomial constructed by this object is a global polynomial, not a piecewise polynomial. Given N data points, the polynoial will be of degree 2 * N - 1. As N increases, the interpolating polynomial may be liable to oscillations that do not properly represent the data. For large data sets, a piecewise polynomial approach is recommended. See either the polynomial_interpolator or spline_interpolator types.

This implementation is a modification of the HERMITE library which can be found here.


Contents


Type-Bound Procedures

procedure, public :: initialize => hi_init

  • private subroutine hi_init(this, x, y, yp, err)

    Initializes the interpolation object.

    Arguments

    Type IntentOptional Attributes Name
    class(hermite_interpolator), intent(inout) :: this

    The hermite_interpolator object.

    real(kind=real64), intent(in), dimension(:) :: x

    An N-element array containing the x-coordinate data in either monotonically increasing or decreasing order.

    real(kind=real64), intent(in), dimension(:) :: y

    An N-element array containing the y-coordinate data.

    real(kind=real64), intent(in), dimension(:) :: yp

    An N-element array containing the first derivative of the data.

    class(errors), intent(inout), optional, target :: err

    An error handling object.

procedure, public :: interpolate => hi_interp

  • private subroutine hi_interp(this, x, yi, err)

    Performs the interpolation.

    Arguments

    Type IntentOptional Attributes Name
    class(hermite_interpolator), intent(inout) :: this

    The hermite_interpolator object.

    real(kind=real64), intent(in), dimension(:) :: x

    An N-element array containing the x values at which to compute the interpolation.

    real(kind=real64), intent(out), dimension(:) :: yi

    An N-element array containing the interpolated data.

    class(errors), intent(inout), optional, target :: err

    An error handling object.

procedure, public :: interpolate_value => hi_raw_interp

  • private function hi_raw_interp(this, x) result(rst)

    Interpolates a single value.

    Arguments

    Type IntentOptional Attributes Name
    class(hermite_interpolator), intent(inout) :: this

    The hermite_interpolator object.

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

    The value at which to compute the interpolation.

    Return Value real(kind=real64)

    The interpolated value.

procedure, public :: interpolate_with_derivative => hi_interp_all

  • private subroutine hi_interp_all(this, x, yi, ypi, err)

    Performs the interpolation.

    Arguments

    Type IntentOptional Attributes Name
    class(hermite_interpolator), intent(inout) :: this

    The hermite_interpolator object.

    real(kind=real64), intent(in), dimension(:) :: x

    An N-element array containing the x values at which to compute the interpolation.

    real(kind=real64), intent(out), dimension(:) :: yi

    An N-element array containing the interpolated data.

    real(kind=real64), intent(out), optional, dimension(:) :: ypi

    An N-element array containing the interpolated first derivative data, if supplied.

    class(errors), intent(inout), optional, target :: err

    An error handling object.