XLPack 7.0
XLPack Numerical Library (Excel VBA) Reference Manual
Loading...
Searching...
No Matches

◆ Bintk()

Sub Bintk ( X() As  Double,
Y() As  Double,
T() As  Double,
N As  Long,
K As  Long,
Bcoef() As  Double,
Q() As  Double,
Info As  Long 
)

B-representation of the spline interpolation of order k

Purpose
This routine computes the B-representation (T(), Bcoef(), N, K) of the spline of order k which interpolates given data. The spline or any of its derivatives can be evaluated by calls to Bvalu.
Parameters
[in]X()Array X(LX - 1) (LX >= Ndata)
X vector of abscissae, distinct and in increasing order.
[in]Y()Array Y(LY - 1) (LY >= Ndata)
Y vector of ordinates.
[in]T()Array T(LT - 1) (LT >= N + K)
Knot vector.
Since T(0), ..., T(K-1) <= X(0) and T(N), ..., T(N+K-1) >= X(N-1), this leaves only N-K knots (not necessarily X(i) values) interior to [X(0), X(N-1)].
[in]NNumber of data points. (N >= K)
[in]KOrder of the spline. (K >= 1)
[out]Bcoef()Array Bcoef(LBcoef - 1) (LBcoef >= N)
B-spline coefficient array.
[out]Q()Array Q(LQ - 1) (LQ >= (2*K - 1)*N)
Triangular factorization of the coefficient matrix of the linear system being solved. The coefficients for the interpolant of an additional data set (X(i), YY(i)) (i = 1 to N) with the same abscissa can be obtained by loading YY() into Bcoef() and then executing the following statement.
  Call Banslv(N, K - 1, K - 1, Q(), Bcoef())
[out]Info= 0: Successful exit.
= -1: The argument X() had an illegal value. (not distinct or not in increasing ordered)
= -2: The argument Y() is invalid.
= -3: The argument T() is invalid.
= -4: The argument N had an illegal value. (N < K)
= -5: The argument K had an illegal value. (K < 1)
= -6: The argument Bcoef() is invalid.
= -7: The argument Q() is invalid.
= 1: Some abscissa was not in the support of the corresponding basis function and the system is singular.
= 2: The system of solver detects a singular system although the theoretical conditions for a solution were satisfied.
Reference
SLATEC
Example Program
Compute ln(0.115) by interpolating the following natural logarithm table with B-representation of the cubic spline.
  x       ln(x)
------ ---------
 0.10   -2.3026
 0.11   -2.2073
 0.12   -2.1203
 0.13   -2.0402
------ ---------
Sub Ex_Bintk()
Const N = 4, K = 4
Dim X(N - 1) As Double, Y(N - 1) As Double, Xe As Double
Dim T(N + K - 1) As Double, Bcoef(N - 1) As Double, Q((2 * K - 1) * N - 1) As Double
Dim Ideriv As Long, Inbv As Long, Info As Long, I As Long
'-- Data
X(0) = 0.1: Y(0) = -2.3026
X(1) = 0.11: Y(1) = -2.2073
X(2) = 0.12: Y(2) = -2.1203
X(3) = 0.13: Y(3) = -2.0402
'-- B-representation of cubic spline interpolation of order k
For I = 0 To N - K + 1
T(I + K - 1) = X(0) + I * (X(N - 1) - X(0)) / (N - K + 1)
Next
T(0) = T(3): T(1) = T(3): T(2) = T(3)
T(7) = T(4): T(6) = T(4): T(5) = T(4)
Call Bintk(X(), Y(), T(), N, K, Bcoef(), Q(), Info)
If Info <> 0 Then
Debug.Print "Error in Bintk: Info =", Info
Exit Sub
End If
'-- Compute interpolated value
Ideriv = 0: Inbv = 1
Xe = 0.115
Debug.Print "ln(" + CStr(Xe) + ") =", Bvalue(T(), Bcoef(), N, K, Ideriv, Xe, Inbv, Info)
Debug.Print "Info =", Info
End Sub
Sub Bintk(X() As Double, Y() As Double, T() As Double, N As Long, K As Long, Bcoef() As Double, Q() As Double, Info As Long)
B-representation of the spline interpolation of order k
Function Bvalue(T() As Double, A() As Double, N As Long, K As Long, Ideriv As Long, X As Double, Inbv As Long, Info As Long) As Double
Evaluation of function or derivative value for B-representation of B-spline
Example Results
ln(0.115) = -2.16285
Info = 0