This section contains the interpolation subroutine descriptions.
These subroutines compute the Newton divided difference coefficients and
perform a polynomial interpolation through a set of data points at specified
abscissas.
x, y, c, t, s | Subroutine |
Short-precision real | SPINT |
Long-precision real | DPINT |
Fortran | CALL SPINT | DPINT (x, y, n, c, ninit, t, s, m) |
C and C++ | spint | dpint (x, y, n, c, ninit, t, s, m); |
PL/I | CALL SPINT | DPINT (x, y, n, c, ninit, t, s, m); |
If ninit <= 0, all elements of c are undefined on entry.
If ninit > 0, c contains the Newton divided difference coefficients, cj for j = 1, ninit, for the interpolating polynomial through the data points (xj,yj) for j = 1, ninit. If ninit < n, the values of cj for j = ninit+1, n are undefined.
Specified as: a one-dimensional array of (at least) length n, containing numbers of the data type indicated in Table 150.
If ninit <= 0, this is the first call to this subroutine with the data in x and y; therefore, none of the Newton divided difference coefficients in c have been initialized.
If ninit > 0, a previous call to this subroutine was made with the data points (xj, yj) for j = 1, ninit, where:
Specified as: a fullword integer; ninit <= n.
Polynomial interpolation is performed at specified abscissas, ti for i = 1, m, in vector t, using the method of Newton divided differences through the data points:
where:
The interpolated value at each ti is returned in si for i = 1, m. See references [15] and [51]. The interpolating values returned in s are computed using the Newton divided difference coefficients, as defined in the following section.
The divided difference coefficients, cj for j = 1, n, are returned in vector 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. If the number of data points is increased from one call this subroutine to the next, the new coefficients are computed, and the existing coefficients are updated (not recomputed). This feature can be used to test for the convergence of the interpolations through a sequence of an increasingly larger set of points.
The values specified for ninit and m indicate which combination of functions are performed by this subroutine: computing the coefficients, performing the interpolation, or both. If m = 0, only the divided difference coefficients are computed. No interpolation is performed. If n = 0, no computation or interpolation is performed.
The Newton divided differences of the following data points:
are denoted by deltakyj for k = 0, 1, 2, ..., n-1 and j = 1, 2, ..., n-k, and are defined as follows:
The value s of the Newton divided difference form of the interpolating polynomial evaluated at an abscissa t is given by:
Therefore, on output, the coefficients in vector c are as follows:
Also, the interpolating values in s, in terms of c, are as follows for i = 1, m:
None
This example shows a quadratic polynomial interpolation on the initial call with the specified data points; that is, NINIT = 0, and C contains all undefined values. On output, NINIT and C are updated with new values.
X Y N C NINIT T S M | | | | | | | | CALL SPINT( X , Y , 3 , C , 0 , T , S , 2 )
X = (-0.50, 0.00, 1.00) Y = (0.25, 0.00, 1.00) C = ( . , . , . ) T = (-0.2, 0.2)
C = (1.00, 1.00, 1.00) NINIT = 3 S = (0.04, 0.04)
This example shows a quadratic polynomial interpolation on a subsequent call with the same data points specified in Example 1, but using a different set of abscissas in T. In this case, NINIT = N = 3, and C contains the values defined on output in Example 1. On output here, the values in NINIT and C are unchanged.
X Y N C NINIT T S M | | | | | | | | CALL SPINT( X , Y , 3 , C , 3 , T , S , 2 )
X = (-0.50, 0.00, 1.00) Y = (0.25, 0.00, 1.00) C = (1.00, 1.00, 1.00) T = (-0.10, 0.10)
C = (1.00, 1.00, 1.00) NINIT = 3 S = (0.01, 0.01)
This example is the same as Example 2 except that it specifies additional data points on the subsequent call to the subroutine. In this case, 0 < NINIT < N. On output here, the values in NINIT and C are updated. The interpolating polynomial is a degree of 4.
X Y N C NINIT T S M | | | | | | | | CALL SPINT( X , Y , 5 , C , 3 , T , S , 2 )
X = (-0.50, 0.00, 1.00, -1.00, 0.50) Y = (0.25, 0.00, 1.00, 1.10, 0.26) C = (1.00, 1.00, 1.00, . , . ) T = (-0.10, 0.10)
C = (0.04, -0.06, 1.02, -0.56, 0.26) NINIT = 5 S = (0.0072, 0.0130)
These subroutines perform a polynomial interpolation at specified
abscissas, using data points selected from a table of data.
x, y, t, s, aux | Subroutine |
Short-precision real | STPINT |
Long-precision real | DTPINT |
Fortran | CALL STPINT | DTPINT (x, y, n, nint, t, s, m, aux, naux) |
C and C++ | stpint | dtpint (x, y, n, nint, t, s, m, aux, naux); |
PL/I | CALL STPINT | DTPINT (x, y, n, nint, t, s, m, aux, naux); |
If naux = 0 and error 2015 is unrecoverable, aux is ignored.
Otherwise, it is the storage work area used by this subroutine. Its size is specified by naux.
Specified as: an area of storage, containing numbers of the data type indicated in Table 151. On output, the contents are overwritten.
If naux = 0 and error 2015 is unrecoverable, STPINT and DTPINT dynamically allocate the work area used by the subroutine. The work area is deallocated before control is returned to the calling program.
Otherwise, naux >= nint+m.
Polynomial interpolation is performed at specified abscissas, ti for i = 1, m, in vector t, using nint points selected from the following data:
where:
The points (xj, yj), used in the interpolation at a given abscissa ti, are chosen as follows, where k = nint/2:
The interpolated value at each ti is returned in si for i = 1, m. See references [15] and [51]. If n, nint, or m is 0, no computation is performed. For a definition of the polynomial interpolation function performed through a set of data points, see "Function".
Error 2015 is unrecoverable, naux = 0, and unable to allocate work area.
None
This example shows interpolation using two data points--that is, linear interpolation--at each ti value.
X Y N NINT T S M AUX NAUX | | | | | | | | | CALL STPINT( X , Y , 10 , 2 , T , S , 5 , AUX , 7 ) X = (0.0, 0.4, 1.0, 1.5, 2.1, 2.6, 3.0, 3.4, 3.9, 4.3) Y = (1.0, 2.0, 3.0, 4.0, 5.0, 5.0, 4.0, 3.0, 2.0, 1.0) T = (-1.0, 0.1, 1.1, 1.2, 3.9)
S = (-1.5000, 1.2500, 3.2000, 3.4000, 2.0000)
This example shows interpolation using three data points--that is, quadratic interpolation--at each ti value.
X Y N NINT T S M AUX NAUX | | | | | | | | | CALL STPINT( X , Y , 10 , 3 , T , S , 5 , AUX , 8 ) X = (0.0, 0.4, 1.0, 1.5, 2.1, 2.6, 3.0, 3.4, 3.9, 4.3) Y = (1.0, 2.0, 3.0, 4.0, 5.0, 5.0, 4.0, 3.0, 2.0, 1.0) T = (-1.0, 0.1, 1.1, 1.2, 3.9)
S = (-2.6667, 1.2750, 3.2121, 3.4182, 2.0000)
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 152.
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 [51]. 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 )
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) C =(not relevant) T = (-1.000, 2.500, 4.000, 7.000)
* * | 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 )
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) C =(same as output C in Example 3 ) T = (-1.000, 2.500, 4.000, 7.000)
C =(same as output C in Example 3 ) S = (24.762, 1.731, 1.100, 1.776) INIT = 4
These subroutines compute the interpolation values at a specified set of
points, using data defined on a rectangular mesh in the x-y plane.
x, y, Z, t, u, aux, S | Subroutine |
Short-precision real | SCSIN2 |
Long-precision real | DCSIN2 |
Fortran | CALL SCSIN2 | DCSIN2 (x, y, z, n1, n2, ldz, t, u, m1, m2, s, lds, aux, naux) |
C and C++ | scsin2 | dcsin2 (x, y, z, n1, n2, ldz, t, u, m1, m2, s, lds, aux, naux); |
PL/I | CALL SCSIN2 | DCSIN2 (x, y, z, n1, n2, ldz, t, u, m1, m2, s, lds, aux, naux); |
If naux = 0 and error 2015 is unrecoverable, aux is ignored.
Otherwise, it is the storage work area used by this subroutine. Its size is specified by naux.
Specified as: an area of storage, containing numbers of the data type indicated in Table 151. On output, the contents are overwritten.
If naux = 0 and error 2015 is unrecoverable, SCSIN2 and DCSIN2 dynamically allocate the work area used by the subroutine. The work area is deallocated before control is returned to the calling program.
Otherwise, naux >= (10)(max(n1, n2))+(n2+1)(m1)+2(m2).
Interpolation is performed at a specified set of points:
by fitting bicubic spline functions with natural boundary conditions, using the following set of data, defined on a rectangular grid, (xi, yj) for i = 1, n1 and j = 1, n2:
where tk, uh, xi, yj, and zij are elements of vectors t, u, x, and y and matrix Z, respectively. In vectors x and y, elements are assumed to be sorted into ascending order.
The interpolation involves two steps:
with natural boundary conditions, is constructed using the data points:
The following interpolation values are then computed:
with natural boundary conditions, is constructed using the data points:
The following interpolation values are then computed:
See references [51] and [57]. Because natural boundary conditions (zero second derivatives at the end of the ranges) are used for the splines, unless the underlying function has these properties, interpolated values near the boundaries may be less satisfactory than elsewhere. If n1, n2, m1, or m2 is 0, no computation is performed.
Error 2015 is unrecoverable, naux = 0, and unable to allocate work area.
None
This example computes the interpolated values at a specified set of points, given by T and U, from a set of data points defined on a rectangular mesh in the x-y plane, using X, Y, and Z.
X Y Z N1 N2 LDZ T U M1 M2 S LDS AUX NAUX | | | | | | | | | | | | | | CALL SCSIN2( X , Y , Z , 6 , 5 , 6 , T , U , 4 , 3 , S , 4 , AUX , 90 ) X = (0.0, 0.2, 0.3, 0.4, 0.5, 0.7) Y = (0.0, 0.2, 0.3, 0.4, 0.6)
* * | 0.000 0.008 0.027 0.064 0.216 | | 0.008 0.016 0.035 0.072 0.224 | Z = | 0.027 0.035 0.054 0.091 0.243 | | 0.064 0.072 0.091 0.128 0.280 | | 0.125 0.133 0.152 0.189 0.341 | | 0.343 0.351 0.370 0.407 0.559 | * *
T = (0.10, 0.15, 0.25, 0.35) U = (0.05, 0.25, 0.45)
* * | 0.001 0.017 0.095 | S = | 0.003 0.019 0.097 | | 0.016 0.031 0.110 | | 0.043 0.059 0.137 | * *