PLUTO  4.4-patch2
Functions
math_interp.c File Reference

Miscellaneous functions for handling interpolation. More...

#include "pluto.h"

Functions

void MonotoneSplineCoeffs (double *x, double *y, double *dydx, int n, double *a, double *b, double *c, double *d)
 
void SplineCoeffs (double *x, double *f, double dfL, double dfR, int n, double *a, double *b, double *c, double *d)
 

Detailed Description

Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Jan 2, 2014

Function Documentation

◆ MonotoneSplineCoeffs()

void MonotoneSplineCoeffs ( double *  x,
double *  y,
double *  dydx,
int  n,
double *  a,
double *  b,
double *  c,
double *  d 
)

Compute the cubic spline coefficients for interpolating a monotonic dataset known at node values f[k] = f(x[k]) and derivative dfdx(x[k]). The resulting spline will be the smoothest curve that passes through the control points while preserving monotonocity of the dataset but not necessarily continuity of the second derivative. Coefficients will be computed in each interval x[k] < x < x[k+1].

The x[k] may not be equally spaced.

Parameters
[in]x1D array of abscissas
[in]f1D array of function values
[in]dfdx1D array of function derivative
[in]nthe number of function values.
[out]athe x^3 cubic coefficient
[out]bthe x^2 cubic coefficient
[out]cthe x cubic coefficient
[out]dthe (1) cubic coefficient

Reference:

  • "Monotonic cubic spline interpolation", G. Wolberg, I. Alfy, Proceedings of Computer Graphics International (1999)
  • "An energy-minimization framework for monotonic cubic spline interpolation", Wolberg & Alfy, J. of comput. and applied math. (2002) 143, 145

◆ SplineCoeffs()

void SplineCoeffs ( double *  x,
double *  f,
double  dfL,
double  dfR,
int  n,
double *  a,
double *  b,
double *  c,
double *  d 
)

Compute the cubic spline coefficients for interpolating a dataset (not necessarily monotonic) known at node values f[k] = f(x[k]). The resulting spline will be continuous up to the second derivative. Coefficients will be computed in each interval x[k] < x < x[k+1].

The x[k] may not be equally spaced.

Parameters
[in]x1D array of abscissas
[in]f1D array of function values
[in]dfLderivative at the leftmost node
[in]dfRderivative at the rightmost node
[in]nthe number of function values.
[out]athe x^3 cubic coefficient
[out]bthe x^2 cubic coefficient
[out]cthe x cubic coefficient
[out]dthe (1) cubic coefficient

Reference:

  • "Numerical Recipe in C, second edition", Section 3.3.