# dbint4.f

          SUBROUTINE DBINT4 (X, Y, NDATA, IBCL, IBCR, FBCL, FBCR, KNTOPT, T,
         +   BCOEF, N, K, W)
    C***BEGIN PROLOGUE  DBINT4
    C***PURPOSE  Compute the B-representation of a cubic spline
    C            which interpolates given data.
    C***LIBRARY   SLATEC
    C***CATEGORY  E1A
    C***TYPE      DOUBLE PRECISION (BINT4-S, DBINT4-D)
    C***KEYWORDS  B-SPLINE, CUBIC SPLINES, DATA FITTING, INTERPOLATION
    C***AUTHOR  Amos, D. E., (SNLA)
    C***DESCRIPTION
    C
    C     Abstract    **** a double precision routine ****
    C
    C         DBINT4 computes the B representation (T,BCOEF,N,K) of a
    C         cubic spline (K=4) which interpolates data (X(I),Y(I)),
    C         I=1,NDATA.  Parameters IBCL, IBCR, FBCL, FBCR allow the
    C         specification of the spline first or second derivative at
    C         both X(1) and X(NDATA).  When this data is not specified
    C         by the problem, it is common practice to use a natural
    C         spline by setting second derivatives at X(1) and X(NDATA)
    C         to zero (IBCL=IBCR=2,FBCL=FBCR=0.0).  The spline is defined
    C         on T(4) .LE. X .LE. T(N+1) with (ordered) interior knots at
    C         X(I) values where N=NDATA+2.  The knots T(1),T(2),T(3) lie to
    C         the left of T(4)=X(1) and the knots T(N+2), T(N+3), T(N+4)
    C         lie to the right of T(N+1)=X(NDATA) in increasing order.  If
    C         no extrapolation outside (X(1),X(NDATA)) is anticipated, the
    C         knots T(1)=T(2)=T(3)=T(4)=X(1) and T(N+2)=T(N+3)=T(N+4)=
    C         T(N+1)=X(NDATA) can be specified by KNTOPT=1.  KNTOPT=2
    C         selects a knot placement for T(1), T(2), T(3) to make the
    C         first 7 knots symmetric about T(4)=X(1) and similarly for
    C         T(N+2), T(N+3), T(N+4) about T(N+1)=X(NDATA).  KNTOPT=3
    C         allows the user to make his own selection, in increasing
    C         order, for T(1), T(2), T(3) to the left of X(1) and T(N+2),
    C         T(N+3), T(N+4) to the right of X(NDATA) in the work array
    C         W(1) through W(6).  In any case, the interpolation on
    C         T(4) .LE. X .LE. T(N+1) by using function DBVALU is unique
    C         for given boundary conditions.
    C
    C     Description of Arguments
    C
    C         Input      X,Y,FBCL,FBCR,W are double precision
    C           X      - X vector of abscissae of length NDATA, distinct
    C                    and in increasing order
    C           Y      - Y vector of ordinates of length NDATA
    C           NDATA  - number of data points, NDATA .GE. 2
    C           IBCL   - selection parameter for left boundary condition
    C                    IBCL = 1 constrain the first derivative at
    C                             X(1) to FBCL
    C                         = 2 constrain the second derivative at
    C                             X(1) to FBCL
    C           IBCR   - selection parameter for right boundary condition
    C                    IBCR = 1 constrain first derivative at
    C                             X(NDATA) to FBCR
    C                    IBCR = 2 constrain second derivative at
    C                             X(NDATA) to FBCR
    C           FBCL   - left boundary values governed by IBCL
    C           FBCR   - right boundary values governed by IBCR
    C           KNTOPT - knot selection parameter
    C                    KNTOPT = 1 sets knot multiplicity at T(4) and
    C                               T(N+1) to 4
    C                           = 2 sets a symmetric placement of knots
    C                               about T(4) and T(N+1)
    C                           = 3 sets T(I)=W(I) and T(N+1+I)=W(3+I),I=1,3
    C                               where W(I),I=1,6 is supplied by the user
    C           W      - work array of dimension at least 5*(NDATA+2)
    C                    If KNTOPT=3, then W(1),W(2),W(3) are knot values to
    C                    the left of X(1) and W(4),W(5),W(6) are knot
    C                    values to the right of X(NDATA) in increasing
    C                    order to be supplied by the user
    C
    C         Output     T,BCOEF are double precision
    C           T      - knot array of length N+4
    C           BCOEF  - B spline coefficient array of length N
    C           N      - number of coefficients, N=NDATA+2
    C           K      - order of spline, K=4
    C
    C     Error Conditions
    C         Improper  input is a fatal error
    C         Singular system of equations is a fatal error
    C
    C***REFERENCES  D. E. Amos, Computation with splines and B-splines,
    C                 Report SAND78-1968, Sandia Laboratories, March 1979.
    C               Carl de Boor, Package for calculating with B-splines,
    C                 SIAM Journal on Numerical Analysis 14, 3 (June 1977),
    C                 pp. 441-472.
    C               Carl de Boor, A Practical Guide to Splines, Applied
    C                 Mathematics Series 27, Springer-Verlag, New York,
    C                 1978.
    C***ROUTINES CALLED  D1MACH, DBNFAC, DBNSLV, DBSPVD, XERMSG
    C***REVISION HISTORY  (YYMMDD)
    C   800901  DATE WRITTEN
    C   890531  Changed all specific intrinsics to generic.  (WRB)
    C   890531  REVISION DATE from Version 3.2
    C   891214  Prologue converted to Version 4.0 format.  (BAB)
    C   900315  CALLs to XERROR changed to CALLs to XERMSG.  (THJ)
    C   900326  Removed duplicate information from DESCRIPTION section.
    C           (WRB)
    C   920501  Reformatted the REFERENCES section.  (WRB)
    C***END PROLOGUE  DBINT4