|
|
◆ Bsplpp()
| Sub Bsplpp |
( |
T() As |
Double, |
|
|
A() As |
Double, |
|
|
N As |
Long, |
|
|
K As |
Long, |
|
|
C() As |
Double, |
|
|
Xi() As |
Double, |
|
|
Lxi As |
Long, |
|
|
Info As |
Long |
|
) |
| |
B-representation to PP (piecewise polynomial) form of B-spline conversion
- Purpose
- This routine converts the B-representation (T(), A(), N, K) of a B-spline to the PP (piecewise polynomial) form (C(), Xi(), Lxi, K) for use with Ppvalu. Here Xi(), the break point array of length Lxi, is the knot array T() with multiplicities removed. The columns of the matrix C(i,j) contain the right Taylor derivatives for the polynomial expansion about Xi(j) for the intervals Xi(j) <= X <= Xi(j+1), i = 0 to k-1, j = 0 to Lxi-1.
Function Ppvalu evaluates the PP form at a specified point X in Xi(0) <= X <= Xi(Lxi).
- Parameters
-
| [in] | T() | Array T(LT - 1) (LT >= N + K)
Knot vector. |
| [in] | A() | Array A(LA - 1) (LA >= N)
B-spline coefficient array. |
| [in] | N | Number of B-spline coefficients. (N = sum of knot multiplicities - K) |
| [in] | K | Order of the B-spline. (K >= 1) |
| [out] | C() | Array C(LC1 - 1, LC2 - 1) (LC1 >= K, LC2 >= Lxi)
Right derivatives at break points. |
| [out] | Xi() | Array Xi(LXi - 1) (LXi >= Lxi + 1)
Break points. |
| [out] | Lxi | Number of polynomial pieces. (Lxi <= N - K + 1) |
| [out] | Info | = 0: Successful exit.
= -1: The argument T() is invalid.
= -2: The argument A() is invalid.
= -3: The argument N had an illegal value. (N < K)
= -4: The argument K had an illegal value. (K < 1)
= -5: The argument C() is invalid.
= -6: The argument Xi() is invalid. |
- Reference
- SLATEC
- Example Program
- Compute the interpolation of the following natural logarithm table with B-representation of the cubic spline using Bint4. After converting its coefficients to PP form, compute the interpolated value of ln(0.115).
x ln(x)
------ ---------
0.10 -2.3026
0.11 -2.2073
0.12 -2.1203
0.13 -2.0402
------ ---------
Sub Ex_Bsplpp()
Const Ndata = 4
Dim X(Ndata - 1) As Double, Y(Ndata - 1) As Double, Xe As Double
Dim Ibcl As Long, Ibcr As Long, Fbcl As Double, Fbcr As Double, Kntopt As Long
Dim T(Ndata + 5) As Double, Bcoef(Ndata + 1) As Double, N As Long, K As Long
Dim Lxi As Long, C(3, Ndata - 2) As Double, Xi(Ndata - 1) As Double
Dim Ideriv As Long, Inppv As Long, Info 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
Ibcl = 2: Fbcl = 0: Ibcr = 2: Fbcr = 0 '-- Natural spline
Kntopt = 1
Call Bint4(X(), Y(), Ndata, Ibcl, Ibcr, Fbcl, Fbcr, Kntopt, T(), Bcoef(), N, K, Info)
If Info <> 0 Then
Debug.Print "Error in Bint4: Info =", Info
Exit Sub
End If
'-- Convert to PP form
Call Bsplpp(T(), Bcoef(), N, K, C(), Xi(), Lxi, Info)
If Info <> 0 Then
Debug.Print "Error in Bsplpp: Info =", Info
Exit Sub
End If
'-- Compute interpolated value
Ideriv = 0: Inppv = 1
Xe = 0.115
Debug.Print "ln(" + CStr(Xe) + ") =", Ppvalu(C(), Xi(), Lxi, K, Ideriv, Xe, Inppv, Info)
Debug.Print "Info =", Info
End Sub
Sub Bint4(X() As Double, Y() As Double, Ndata As Long, Ibcl As Long, Ibcr As Long, Fbcl As Double, Fbcr As Double, Kntopt As Long, T() As Double, Bcoef() As Double, N As Long, K As Long, Info As Long) B-representation of the cubic spline interpolation
Function Ppvalu(C() As Double, Xi() As Double, Lxi As Long, K As Long, Ideriv As Long, X As Double, Inppv As Long, Info As Long) As Double Evaluation of function or derivative value for PP (piecewise polynomial) form of B-spline
Sub Bsplpp(T() As Double, A() As Double, N As Long, K As Long, C() As Double, Xi() As Double, Lxi As Long, Info As Long) B-representation to PP (piecewise polynomial) form of B-spline conversion
- Example Results
ln(0.115) = -2.16266
Info = 0
|