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