These subroutines compute the coefficients of the cubic spline through a
set of data points and evaluate the spline at specified abscissas.
x, y, C, t, s | Subroutine |
Short-precision real | SCSINT |
Long-precision real | DCSINT |
Fortran | CALL SCSINT | DCSINT (x, y, c, n, init, t, s, m) |
C and C++ | scsint | dcsint (x, y, c, n, init, t, s, m); |
PL/I | CALL SCSINT | DCSINT (x, y, c, n, init, t, s, m); |
If init <= 0, all elements of c are undefined on entry.
If init = 1, c11 contains the spline derivative at x1.
If init = 2, c21 contains the spline derivative at xn.
If init = 3, c11 contains the spline derivative at x1, and c21 contains the spline derivative at xn.
If init > 3, c contains the coefficients of the spline computed for the data points (xj,yj) for j = 1, n on a previous call to this subroutine.
Specified as: an n by (at least) 4 array, containing numbers of the data type indicated in Table 157.
If init <= 0, the coefficients are uninitialized. The second derivatives of the spline at x1 and xn are set to zero. (These are free end conditions, also called natural boundary conditions.)
If init = 1, the coefficients are uninitialized. The value in c11 is used as the spline derivative at x1.
If init = 2, the coefficients are uninitialized. The value in c21 is used as the spline derivative at xn.
If init = 3, the coefficients are uninitialized. The value in c11 is used as the spline derivative at x1 and the value in c21 is used as the spline derivative at xn.
If init > 3, the coefficients in c were computed for data points (xj, yj) for j = 1, n on a previous call to this subroutine.
Specified as: a fullword integer. It can have any value.
Interpolation is performed at specified abscissas, ti for i = 1, m, in vector t, using the cubic spline passing through the data points:
where:
The value of the cubic spline at each ti is returned in si for i = 1, m. See references [15] and [54]. The coefficients of the spline, cjk for j = 1, n and k = 1, 4, are returned in matrix C. These coefficients can then be reused on subsequent calls to this subroutine, using the same data points (xj, yj), but with new values of ti. The cubic spline values returned in s are computed using the coefficients as follows:
where:
The values specified for m and init indicate which combination of functions are performed by this subroutine:
In addition, if n = 0, no computation is performed.
The values specified for n and init determine the type of spline function:
None
This example computes the spline coefficients through a set of data points with no derivative value specified. It also evaluates the spline at the abscissas specified in T. On output, INIT and C are updated with new values.
X Y C N INIT T S M | | | | | | | | CALL SCSINT( X , Y , C , 6 , 0 , T , S , 4 )
* * | 0.000 -0.868 0.000 -0.132 | | 1.000 -1.264 0.396 -0.132 | C = | 2.000 -0.076 -1.585 0.660 | | 1.100 1.267 0.243 -0.609 | | 0.000 1.010 0.014 0.076 | | -1.000 0.995 0.000 0.005 | * *
INIT = 4 S = (-2.792, 1.649, 1.100, -2.000)
This example computes the spline coefficients through a set of data points with a derivative value specified at the right endpoint. It also evaluates the spline at the abscissas specified in T. On output, INIT and C are updated with new values.
X Y C N INIT T S M | | | | | | | | CALL SCSINT( X , Y , C , 6 , 2 , T , S , 4 ) X = (1.000, 2.000, 3.000, 4.000, 5.000, 6.000) Y = (0.000, 1.000, 2.000, 1.100, 0.000, -1.000)
* * | . . . . | | 0.1 . . . | C = | . . . . | | . . . . | | . . . . | | . . . . | * * T = (-1.000, 2.500, 4.000, 7.000)
* * | 0.000 -0.865 0.000 -0.135 | | 1.000 -1.270 0.405 -0.135 | C = | 2.000 -0.054 -1.621 0.675 | | 1.100 1.188 0.379 -0.667 | | 0.000 1.303 -0.494 0.291 | | -1.000 0.100 1.897 -0.797 | * * INIT = 4 S = (-2.810, 1.652, 1.100, 1.794)
This example computes the spline coefficients through a set of data points with a derivative value specified at both endpoints. It does not evaluate the spline at any points. On output, INIT and C are updated with new values. Because arrays are not needed for arguments t and s, the value 0 is specified in their place.
X Y C N INIT T S M | | | | | | | | CALL SCSINT( X , Y , C , 6 , 3 , 0 , 0 , 0 ) X = (1.000, 2.000, 3.000, 4.000, 5.000, 6.000) Y = (0.000, 1.000, 2.000, 1.100, 0.000, -1.000)
* * | -1.0 . . . | | 0.1 . . . | C = | . . . . | | . . . . | | . . . . | | . . . . | * *
* * | 0.000 1.000 3.230 1.230 | | 1.000 -1.770 -0.460 1.230 | C = | 2.000 0.079 -1.389 0.310 | | 1.100 1.152 0.316 -0.568 | | 0.000 1.312 -0.476 0.264 | | -1.000 -0.100 1.888 -0.788 | * * INIT = 4
This example evaluates the spline at a set of points, using the coefficients obtained in Example 3.
X Y C N INIT T S M | | | | | | | | CALL SCSINT( X , Y , C , 6 , 4 , T , S , 4 )