/* *** spline.h -- header file for spline functions, see spline.c */ #ifndef SPLINE_H #define SPLINE_H #include "error.h" #define spline_error(mesg) (*error_handler)(__FILE__,__LINE__,mesg) typedef struct { /* See Atkinson: Intro Numer Anal, 2nd Ed'n, pp. 166-173 */ int length; double *xlist; /* list of knots */ double *ylist; /* values interpolated */ double *Mlist; /* 2nd derivatives at knots */ } spline; /* spline_create -- allocates spline structure with the desired length */ spline *spline_create(int length); /* spline_destroy -- frees spline structure memory */ void spline_destroy(spline *s); /* spline_print -- prints a representation of the spline s to the stream fp */ void spline_print(FILE *fp, spline *s); /* spline_read -- reads a representation of a spline from stream fp and return the spline */ spline *spline_read(FILE *fp); /* spline_setxy -- copies the knot and interpolation values into xlist and ylist */ spline *spline_setxy(spline *s, double x[], double y[], int length); /* spline_eval -- evaluates spline s at point t */ double spline_eval(spline *s, double t); /* spline_make_natural -- constructs natural spline using knots and values (xlist & ylist resp.) in s */ spline *spline_make_natural(spline *s); /* spline_make_periodic -- constructs periodic spline using knots and values in s; must have ylist[length-1] == ylist[0] for periodicity */ spline *spline_make_periodic(spline *s); /* spline_make_clamped -- constructs clamped spline using knots and values in s, but with end-point derivatives dy0 at xlist[0] and dy_end at xlist[length-1] */ spline *spline_make_clamped(spline *s, double dy0, double dy_end); #endif /* SPLINE_H */