The gslinterp
module provides S-Lang interpreter access to
GSL's interpolations routines. The interpolation methods include
linear, polynomial, and spline interpolation. Both Cubic and Akima
splines are supported with normal or periodic boundary conditions. In
addition, routines for computing first and second order derivatives,
as well as integrals based upon these interpolation methods are
included.
The wrapping of these functions differs somewhat from the interface
provided by the GSL API in the interest of ease of use. The
gslinterp
modules actual defines two interfaces to the
underlying GSL routines.
The higher-level interface is the simplest to use and should suffice
for most applications. As an example of its use, suppose one has a
set of (x,y) pairs represented by the arrays xa
and ya
that one wants to use for interpolation. Then
y = interp_cspline (x, xa, ya);
will fit a cubic spline to the points and return the of the spline at
the point x
. If x
is an array, then the spline will be
evaluated at each of the points in the array returning an array of
the same shape.
The low-level interface consists of several method-specific initialization functions and functions that carry out the actual interpolation. The above example may be written in terms of this interface as
c = interp_cspline_init (xa, ya);
y = interp_eval (c, x);
Here interp_cspline_init
returns an object of type
GSL_Interp_Type
that represents the spline function. It is
then passed to the interp_eval
function to evaluate the spline
at x
.
The advantage of the lower level interface is that it moves the overhead associated with the computation of the interpolating function (the spline in the above example) out of the function that performs the interpolation. This means that code such as
c = interp_cspline_init (xa, ya);
y0 = interp_eval (c, x0);
y1 = interp_eval (c, x1);
will execute in less time than
y0 = interp_cspline (x0, xa, ya);
y1 = interp_cspline (x1, xa, ya);
Linear Interpolation
y = interp_linear (x, Double_Type xa[], Double_Type ya[])
Use linear interpolation to determine the value at x
given the
points (xa
, ya
). The first argument, x
, may be
either a scalar or an array, and a result of the corresponding type
will be returned.
interp_polynomial,
interp_cspline,
interp_cspline_periodic,
interp_akima,
interp_akima_periodic
Polynomial Interpolation
y = interp_polynomial (x, Double_Type xa[], Double_Type ya[])
Use polynomial interpolation to determine the value at x
given the
points (xa
, ya
). The first argument, x
, may be
either a scalar or an array, and a result of the corresponding type
will be returned.
The degree of the interpolating polynomial is given by one less than
the number of points in the xa
array. For example, if
length(xa)
is 3, then a quadratic polynomial will be used.
interp_linear,
interp_cspline,
interp_cspline_periodic,
interp_akima,
interp_akima_periodic
Cubic Spline Interpolation
y = interp_cspline (x, Double_Type xa[], Double_Type ya[])
Use cubic spline interpolation with natural boundary conditions to
determine the value at x
given the points (xa
,
ya
). The first argument, x
, may be either a scalar or
an array, and a result of the corresponding type will be returned.
interp_linear,
interp_polynomial,
interp_cspline_periodic,
interp_akima,
interp_akima_periodic
Cubic spline interpolation with periodic boundary conditions
y = interp_cspline_periodic (x, Double_Type xa[], Double_Type ya[])
Use cubic spline interpolation with periodic boundary conditions to
determine the value at x
given the points (xa
,
ya
). The first argument, x
, may be either a scalar or
an array, and a result of the corresponding type will be returned.
interp_linear,
interp_polynomial,
interp_cspline,
interp_akima,
interp_akima_periodic
Akima spline interpolation
y = interp_akima (x, Double_Type xa[], Double_Type ya[])
Use an Akima spline with natural boundary conditions to
determine the value at x
given the points (xa
,
ya
). The first argument, x
, may be either a scalar or
an array, and a result of the corresponding type will be returned.
interp_linear,
interp_polynomial,
interp_cspline,
interp_cspline_periodic,
interp_akima_periodic
Akima spline interpolation with periodic boundary conditions
y = interp_akima_periodic (x, Double_Type xa[], Double_Type ya[])
Use an Akima spline with periodic boundary conditions to
determine the value at x
given the points (xa
,
ya
). The first argument, x
, may be either a scalar or
an array, and a result of the corresponding type will be returned.
interp_linear,
interp_polynomial,
interp_cspline,
interp_cspline_periodic,
interp_akima
Compute derivative using linear interpolation
y = interp_linear_deriv (x, Double_Type xa[], Double_Type ya[])
Use linear interpolation to determine the value of the first
derivative at x
given the points (xa
, ya
). The
first argument, x
, may be either a scalar or an array, and a
result of the corresponding type will be returned.
interp_polynomial_deriv,
interp_cspline_deriv,
interp_cspline_periodic_deriv,
interp_akima_deriv,
interp_akima_periodic_deriv
Compute derivative using polynomial interpolation
y = interp_polynomial_deriv (x, Double_Type xa[], Double_Type ya[])
Use polynomial interpolation to determine the value of the first
derivative at x
given the points (xa
, ya
). The
first argument, x
, may be either a scalar or an array, and a
result of the corresponding type will be returned.
The degree of the interpolating polynomial is given by one less than
the number of points in the xa
array. For example, if
length(xa)
is 3, then a quadratic polynomial will be used.
interp_linear_deriv,
interp_cspline_deriv,
interp_cspline_periodic_deriv,
interp_akima_deriv,
interp_akima_periodic_deriv
Compute derivative using a cubic spline
y = interp_cspline_deriv (x, Double_Type xa[], Double_Type ya[])
Use cubic spline interpolation with natural boundary conditions to
determine the value of the first derivative at x
given the
points (xa
, ya
). The first argument, x
, may be
either a scalar or an array, and a result of the corresponding type
will be returned.
interp_linear_deriv,
interp_polynomial_deriv,
interp_cspline_periodic_deriv,
interp_akima_deriv,
interp_akima_periodic_deriv
Compute derivative using a cubic spline
y = interp_cspline_periodic_deriv (x, Double_Type xa[], Double_Type ya[])
Use cubic spline interpolation with periodic boundary conditions to
determine the value of the first derivative at x
given the
points (xa
, ya
). The first argument, x
, may be
either a scalar or an array, and a result of the corresponding type
will be returned.
interp_linear_deriv,
interp_polynomial_deriv,
interp_cspline_deriv,
interp_akima_deriv,
interp_akima_periodic_deriv
Compute derivative using an Akima spline
y = interp_akima_deriv (x, Double_Type xa[], Double_Type ya[])
Use Akima spline interpolation with natural boundary conditions to
determine the value of the first derivative at x
given the
points (xa
, ya
). The first argument, x
, may be
either a scalar or an array, and a result of the corresponding type
will be returned.
interp_linear_deriv,
interp_polynomial_deriv,
interp_cspline_deriv,
interp_cspline_periodic_deriv,
interp_akima_periodic_deriv
Compute derivative using an Akima spline
y = interp_cspline_deriv (x, Double_Type xa[], Double_Type ya[])
Use Akima spline interpolation with periodic boundary conditions to
determine the value of the first derivative at x
given the
points (xa
, ya
). The first argument, x
, may be
either a scalar or an array, and a result of the corresponding type
will be returned.
interp_linear_deriv,
interp_polynomial_deriv,
interp_cspline_deriv,
interp_cspline_periodic_deriv,
interp_akima_deriv
Compute second derivative using linear interpolation
y = interp_linear_deriv2 (x, Double_Type xa[], Double_Type ya[])
Use linear interpolation to determine the value of the second
derivative at x
given the points (xa
, ya
). The
first argument, x
, may be either a scalar or an array, and a
result of the corresponding type will be returned.
interp_polynomial_deriv2,
interp_cspline_deriv2,
interp_cspline_periodic_deriv2,
interp_akima_deriv2,
interp_akima_periodic_deriv2
Compute second derivative using polynomial interpolation
y = interp_polynomial_deriv2 (x, Double_Type xa[], Double_Type ya[])
Use polynomial interpolation to determine the value of the second
derivative at x
given the points (xa
, ya
). The
first argument, x
, may be either a scalar or an array, and a
result of the corresponding type will be returned.
The degree of the interpolating polynomial is given by one less than
the number of points in the xa
array. For example, if
length(xa)
is 3, then a quadratic polynomial will be used.
interp_linear_deriv2,
interp_cspline_deriv2,
interp_cspline_periodic_deriv2,
interp_akima_deriv2,
interp_akima_periodic_deriv2
Compute second derivative using a cubic spline
y = interp_cspline_deriv2 (x, Double_Type xa[], Double_Type ya[])
Use cubic spline interpolation with natural boundary conditions to
determine the value of the second derivative at x
given the
points (xa
, ya
). The first argument, x
, may be
either a scalar or an array, and a result of the corresponding type
will be returned.
interp_linear_deriv2,
interp_polynomial_deriv2,
interp_cspline_periodic_deriv2,
interp_akima_deriv2,
interp_akima_periodic_deriv2
Compute second derivative using a cubic spline
y = interp_cspline_periodic_deriv2 (x, Double_Type xa[], Double_Type ya[])
Use cubic spline interpolation with periodic boundary conditions to
determine the value of the second derivative at x
given the
points (xa
, ya
). The first argument, x
, may be
either a scalar or an array, and a result of the corresponding type
will be returned.
interp_linear_deriv2,
interp_polynomial_deriv2,
interp_cspline_deriv2,
interp_akima_deriv2,
interp_akima_periodic_deriv2
Compute second derivative using an Akima spline
y = interp_akima_deriv2 (x, Double_Type xa[], Double_Type ya[])
Use Akima spline interpolation with natural boundary conditions to
determine the value of the second derivative at x
given the
points (xa
, ya
). The first argument, x
, may be
either a scalar or an array, and a result of the corresponding type
will be returned.
interp_linear_deriv2,
interp_polynomial_deriv2,
interp_cspline_deriv2,
interp_cspline_periodic_deriv2,
interp_akima_periodic_deriv2
Compute second derivative using an Akima spline
y = interp_cspline_deriv2 (x, Double_Type xa[], Double_Type ya[])
Use Akima spline interpolation with periodic boundary conditions to
determine the value of the second derivative at x
given the
points (xa
, ya
). The first argument, x
, may be
either a scalar or an array, and a result of the corresponding type
will be returned.
interp_linear_deriv2,
interp_polynomial_deriv2,
interp_cspline_deriv2,
interp_cspline_periodic_deriv2,
interp_akima_deriv2,
interp_akima_periodic_deriv2
Compute an integral using linear interpolation
y = interp_linear_integ (Double_Type xa[], Double_Type ya[], a, b)
This function computes the integral from a
to b
of the
linear interpolating function associated with the set of points
(xa
, ya
). See interp_linear
for more
information about the interpolating function.
interp_polynomial_integ,
interp_cspline_integ,
interp_cspline_periodic_integ,
interp_akima_integ,
interp_akima_periodic_integ
Compute an integral using polynomial interpolation
y = interp_polynomial_integ (Double_Type xa[], Double_Type ya[], a, b)
This function computes the integral from a
to b
of the
polynomial interpolating function associated with the set of points
(xa
, ya
). See interp_polynomial
for more
information about the interpolating function.
interp_linear_integ,
interp_cspline_integ,
interp_cspline_periodic_integ,
interp_akima_integ,
interp_akima_periodic_integ
Compute an integral using a cubic spline
y = interp_cspline_integ (Double_Type xa[], Double_Type ya[], a, b)
This function computes the integral from a
to b
of the
cubic spline interpolating function associated with the set of points
(xa
, ya
). See interp_cspline
for more
information about the interpolating function.
interp_linear_integ,
interp_polynomial_integ,
interp_cspline_periodic_integ,
interp_akima_integ,
interp_akima_periodic_integ
Compute an integral using a cubic spline
y = interp_cspline_periodic_integ (Double_Type xa[], Double_Type ya[], a, b)
This function computes the integral from a
to b
of the
cubic spline interpolating function associated with the set of points
(xa
, ya
). See interp_cspline_periodic
for more
information about the interpolating function.
interp_linear_integ,
interp_polynomial_integ,
interp_cspline_integ,
interp_akima_integ,
interp_akima_periodic_integ
Compute an integral using an Akima spline
y = interp_akima_integ (Double_Type xa[], Double_Type ya[], a, b)
This function computes the integral from a
to b
of the
Akima spline interpolating function associated with the set of points
(xa
, ya
). See interp_akima
for more
information about the interpolating function.
interp_linear_integ,
interp_polynomial_integ,
interp_cspline_integ,
interp_cspline_periodic_integ,
interp_akima_periodic_integ
Compute an integral using an Akima spline
y = interp_cspline_integ (Double_Type xa[], Double_Type ya[], a, b)
This function computes the integral from a
to b
of the
Akima spline interpolating function associated with the set of points
(xa
, ya
). See interp_akima_periodic
for more
information about the interpolating function.
interp_linear_integ,
interp_polynomial_integ,
interp_cspline_integ,
interp_cspline_periodic_integ,
interp_akima_integ
Compute a linear interpolation object
GSL_Interp_Type interp_linear_init (Double_Type_Type xa[], Double_Type_Type ya[])
This function computes an interpolation object appropriate for
linear interpolation on the specified xa
and ya
arrays.
interp_eval,
interp_polynomial_init,
interp_cspline_init,
interp_cspline_periodic_init,
interp_akima_init,
interp_akima_periodic_init
Compute a polynomial interpolation object
GSL_Interp_Type interp_polynomial_init (Double_Type xa[], Double_Type ya[])
This function computes an interpolation object appropriate for
polynomial interpolation on the specified xa
and ya
arrays.
interp_eval,
interp_linear_init,
interp_cspline_init,
interp_cspline_periodic_init,
interp_akima_init,
interp_akima_periodic_init
Compute a cubic spline Interpolation object
GSL_Interp_Type interp_cspline_init (Double_Type xa[], Double_Type ya[])
This function computes an interpolation object appropriate for
cubic spline interpolation with natural boundary conditions on the
specified xa
and ya
arrays.
interp_eval,
interp_linear_init,
interp_polynomial_init,
interp_cspline_periodic_init,
interp_akima_init,
interp_akima_periodic_init
Compute a cubic spline interpolation object
GSL_Interp_Type interp_cspline_periodic_init (Double_Type xa[], Double_Type ya[])
This function computes an interpolation object appropriate for
cubic spline interpolation with periodic boundary conditions on the
specified xa
and ya
arrays.
interp_eval,
interp_linear_init,
interp_polynomial_init,
interp_cspline_init,
interp_akima_init,
interp_akima_periodic_init
Compute an Akima spline interpolation object
GSL_Interp_Type interp_akima_init (Double_Type xa[], Double_Type ya[])
This function computes an interpolation object appropriate for
Akima spline interpolation with natural boundary conditions on the
specified xa
and ya
arrays.
interp_eval,
interp_linear_init,
interp_polynomial_init,
interp_cspline_init,
interp_cspline_periodic_init,
interp_akima_periodic_init
Compute an Akima spline interpolation object
GSL_Interp_Type interp_akima_periodic_init (Double_Type xa[], Double_Type ya[])
This function computes an interpolation object appropriate for
Akima spline interpolation with periodic boundary conditions on the
specified xa
and ya
arrays.
interp_eval,
interp_linear_init,
interp_polynomial_init,
interp_cspline_init,
interp_cspline_periodic_init,
interp_akima_periodic
Evaluate an interpolation object
y = interp_eval (GSL_Interp_Type c, x)
Use the precomputed interpolation object c
to interpolate its
value at x
, which may be either
a scalar or an array. An interpolated value of the corresponding
shape will be returned.
interp_linear_init,
interp_eval_deriv,
interp_eval_deriv2,
interp_eval_integ
Evaluate the derivative of an interpolation object
dydx = interp_eval_deriv (GSL_Interp_Type c, x)
Use the precomputed interpolation object c
to interpolate its
first derivative at x
, which may be either
a scalar or an array. An interpolated value of the corresponding
shape will be returned.
interp_linear_init,
interp_eval,
interp_eval_deriv2,
interp_eval_integ
Evaluate the derivative of an interpolation object
d2ydx2 = interp_eval_deriv2 (GSL_Interp_Type c, x)
Use the precomputed interpolation object c
to interpolate its
second derivative at x
, which may be either
a scalar or an array. An interpolated value of the corresponding
shape will be returned.
interp_linear_init,
interp_eval,
interp_eval_deriv,
interp_eval_integ
Compute the integral of an interpolation object
d2ydx2 = interp_eval_deriv2 (GSL_Interp_Type c, a, b)
Use the precomputed interpolation object c
to interpolate its
integral from a
to b
.
interp_linear_init,
interp_eval,
interp_eval_deriv,
interp_eval_deriv2