DEFINITION MODULE Splines; (* EXPORT QUALIFIED Spline, Splint; *) FROM NRVect IMPORT Vector; PROCEDURE Spline( X, Y: Vector; yp1, ypn: REAL; Y2: Vector); (* Given arrays X[n] and Y[n] containing a tabulated function, i.e. yi = f(xi), with x0 < x1 < ... < x(n-1), and given values yp1 and ypn for the first derivative of the interpolating function at points 0 and n-1, respectively, this routine returns an array Y2[n] that contains the second derivatives of the interpolating function at the tabulated points xi. If yp1 and/or ypn are equal to 1 x 10^30 or larger, the routine is signalled to set the corresponding boundary condition for a natural spline, with zero second derivative on that boundary. *) PROCEDURE Splint( XA, YA, Y2A: Vector; x: REAL; VAR y: REAL); (* Given the arrays XA[n] and YA[n], which tabulate a function (with the XAi's in order), and given the array Y2A[n], which is the output from Spline above, and given a value of x, this routine returns a cubic-spline interpolated value y. *) END Splines.