ampsci
High-precision calculations for one- and two-valence atomic systems
Interpolator Namespace Reference

Detailed Description

1D interpolation using GSL splines.

Wraps the GSL interpolation library (https://www.gnu.org/software/gsl/doc/html/interp.html). Provides a stateful Interp class and a convenience interpolate() function. Several interpolation methods are available via Method. Does not extrapolate: values outside [xmin, xmax] are returned as zero.

Classes

class  Interp
 Stateful 1D interpolation object using GSL. More...
 

Enumerations

enum class  Method {
  linear , polynomial , cspline , cspline_periodic ,
  akima , akima_periodic , steffen
}
 Interpolation method. More...
 

Functions

std::vector< double > interpolate (const std::vector< double > &x_in, const std::vector< double > &y_in, const std::vector< double > &x_out, Method method=Method::cspline)
 Convenience wrapper: interpolates y_in(x_in) and evaluates at x_out.
 

Enumeration Type Documentation

◆ Method

enum class Interpolator::Method
strong

Interpolation method.

See https://www.gnu.org/software/gsl/doc/html/interp.html for full details.

Enumerator
linear 

Linear interpolation; no additional memory required.

polynomial 

Polynomial interpolation; only suitable for small numbers of points.

cspline 

Cubic spline with natural boundary conditions (zero second derivative at endpoints)

cspline_periodic 

Cubic spline with periodic boundary conditions; first and last y-values must match.

akima 

Akima spline with natural boundary conditions (Wodicka non-rounded corner algorithm)

akima_periodic 

Akima spline with periodic boundary conditions.

steffen 

Steffen's monotone spline: no spurious oscillations between data points. GSL v2+ only.

Function Documentation

◆ interpolate()

std::vector< double > Interpolator::interpolate ( const std::vector< double > &  x_in,
const std::vector< double > &  y_in,
const std::vector< double > &  x_out,
Method  method = Method::cspline 
)
inline

Convenience wrapper: interpolates y_in(x_in) and evaluates at x_out.

Parameters
x_inInput x values (strictly increasing).
y_inInput y values; must satisfy y_in.size() == x_in.size().
x_outPoints at which to evaluate the interpolant.
methodInterpolation method (default: cspline).
Returns
Vector of interpolated values at each point in x_out.