%N seval %F $MIR/src/subs/spline.for
%D Evaluate a cubic spline
%P pjt
%: interpolation
%B
      double precision function seval (n, u, x, y, b, c, d)
      implicit none
      integer n
      double precision  u, x(n), y(n), b(n), c(n), d(n)

  this subroutine evaluates the cubic spline function

    seval = y(i) + b(i)*(u-x(i)) + c(i)*(u-x(i))**2 + d(i)*(u-x(i))**3

    where  x(i) .lt. u .lt. x(i+1), using horner's rule

  if  u .lt. x(1) then  i = 1  is used.
  if  u .ge. x(n) then  i = n  is used.

  input..

    n = the number of data points
    u = the abscissa at which the spline is to be evaluated
    x,y = the arrays of data abscissas and ordinates
    b,c,d = arrays of spline coefficients computed by spline

  if  u  is not in the same interval as the previous call, then a
  binary search is performed to determine the proper interval.
