|
|
◆ Bsqad()
| Sub Bsqad |
( |
T() As |
Double, |
|
|
Bcoef() As |
Double, |
|
|
N As |
Long, |
|
|
K As |
Long, |
|
|
X1 As |
Double, |
|
|
X2 As |
Double, |
|
|
Bquad As |
Double, |
|
|
Info As |
Long |
|
) |
| |
Integral of B-representation of B-spline
- Purpose
- This routine computes the integral on [x1, x2] of a K-th order B-spline using the B-representation (T(), Bcoef(), N, K). Orders K as high as 20 are permitted by applying a 2, 6, or 10 point Gauss formula on subintervals of [x1, x2] which are formed by included (distinct) knots. If orders K greater than 20 are needed, use Bfqad with f(x) = 1.
- Parameters
-
| [in] | T() | Array T(LT - 1) (LT >= N + K)
Knot vector. |
| [in] | Bcoef() | Array Bcoef(LBcoef - 1) (LBcoef >= N)
B-spline coefficients. |
| [in] | N | Number of B-spline coefficients. (N = sum of knot multiplicities - K) |
| [in] | K | Order of the B-spline. (1 <= K <= 20) |
| [in] | X1 | Lower end point of quadrature interval. (T(K) <= X1 <= T(N+1)) |
| [in] | X2 | Upper end point of quadrature interval. (T(K) <= X2 <= T(N+1)) |
| [out] | Bquad | Integral of the B-spline over [X1, X2]. |
| [out] | Info | = 0: Successful exit.
= -1: The argument T() is invalid.
= -2: The argument Bcoef() is invalid.
= -3: The argument N had an illegal value. (N < K)
= -4: The argument K had an illegal value. (K < 1 or K > 20)
= -5: The argument X1 had an illegal value. (X1 < T(K) or X1 > T(N+1))
= -6: The argument X2 had an illegal value. (X2 < T(K) or X2 > T(N+1)) |
- Reference
- SLATEC
- Example Program
- Using the following table, compute S = integral of 1/(1 + x^2) dx [0, 4] (= atan(4)).
x 1/(1 + x^2)
----- -------------
-1 0.5
0 1
1 0.5
2 0.2
3 0.1
4 0.05882
5 0.03846
----- -------------
Sub Ex_Bsqad()
Const Ndata = 7, A = 0, B = 4
Dim X(Ndata - 1) As Double, Y(Ndata - 1) As Double, D(Ndata - 1) 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 Info As Long, S As Double
'-- Data
X(0) = -1: Y(0) = 0.5
X(1) = 0: Y(1) = 1
X(2) = 1: Y(2) = 0.5
X(3) = 2: Y(3) = 0.2
X(4) = 3: Y(4) = 0.1
X(5) = 4: Y(5) = 0.05882
X(6) = 5: Y(6) = 0.03846
'-- B-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
'-- Compute integral 1/(1 + x^2) dx [0, 4] (= atan(4))
Call Bsqad(T(), Bcoef(), N, K, A, B, S, Info)
Debug.Print "S =", S, "S(true) =", Atn(4)
Debug.Print "Info =", Info
End Sub
Sub Bsqad(T() As Double, Bcoef() As Double, N As Long, K As Long, X1 As Double, X2 As Double, Bquad As Double, Info As Long) Integral of B-representation of B-spline
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
- Example Results
S = 1.32679961538462 S(true) = 1.32581766366803
Info = 0
|