|
|
◆ Pfqad_r()
| Sub Pfqad_r |
( |
C() As |
Double, |
|
|
Xi() As |
Double, |
|
|
Lxi As |
Long, |
|
|
K As |
Long, |
|
|
Id As |
Long, |
|
|
X1 As |
Double, |
|
|
X2 As |
Double, |
|
|
Tol As |
Double, |
|
|
Quad As |
Double, |
|
|
Info As |
Long, |
|
|
XX As |
Double, |
|
|
YY As |
Double, |
|
|
IRev As |
Long |
|
) |
| |
Integral of product of arbitrary function and PP (piecewise polynomial) form of B-spline (reverse communication version)
- Purpose
- This routine computes the integral on [X1, X2] of a product of a function f(x) and the Id-th derivative of a K-th order B-spline, using the PP-representation (C(), Xi(), Lxi, K). [X1, X2] is normally a subinterval of [Xi(0), Xi(Lxi)].
The integration routine using adaptive 8-point Gauss-Legendre rule integrates the product on subintervals of [X1, X2] formed by included break points. Integration outside of [Xi(0), Xi(Lxi)] is permitted provided f is defined.
- Parameters
-
| [in] | C() | Array C(LC1 - 1, LC2 - 1) (LC1 >= K, LC2 >= Lxi)
Right derivatives at break points. |
| [in] | Xi() | Array Xi(LXi - 1) (LXi >= Lxi + 1)
Break points. |
| [in] | Lxi | Number of polynomial pieces. |
| [in] | K | Order of the B-spline. (K >= 1) |
| [in] | Id | Order of the spline derivative. (0 <= Id <= K - 1)
Id = 0 gives the spline function. |
| [in] | X1 | Lower end point of quadrature interval. (Normally Xi(0) <= X1 <= Xi(Lxi)) |
| [in] | X2 | Upper end point of quadrature interval. (Normally Xi(0) <= X2 <= Xi(Lxi)) |
| [in] | Tol | Desired accuracy for the quadrature. (Eps < Tol <= 0.1, where Eps is the double precision unit roundoff (= D1mach(4))) |
| [out] | Quad | Integral of f(x)*(Id-th derivative of a K-th order B-spline) on [X1, X2]. |
| [out] | Info | = 0: Successful exit.
= -1: The argument C() is invalid.
= -2: The argument Xi() is invalid.
= -3: The argument Lxi had an illegal value. (Lxi < 1)
= -4: The argument K had an illegal value. (K < 1)
= -5: The argument Id had an illegal value. (Id < 0 or Id >= K)
= -8: The argument Tol had an illegal value. (Tol < DTol or Tol > 0.1)
= 1: Some quadrature on (X1, X2) does not meet the requested tolerance. |
| [out] | XX | When returned with IRev = 1, XX contains the abscissa where the function value should be evaluated and given in the next call. |
| [in] | YY | When returned with IRev = 1, the function value f(XX) should be given in YY in the next call. |
| [in,out] | IRev | Control variable for reverse communication.
[in] Before first call, IRev should be initialized to zero. On succeeding calls, IRev should not be altered.
[out] If IRev is not zero, set the required values to the specified variable as follows and call the routine again.
= 0: Computation finished. See return code in Info.
= 1: User should set the function values at XX in YY. Do not alter any variables other than YY. |
- Reference
- SLATEC
- Example Program
- Using the following table, compute S = integral of 1/(1 + x^2) dx [0, 4] (= atan(4)). (f(x) = 1)
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_Pfqad_r()
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 Lxi As Long, C(3, Ndata - 2) As Double, Xi(Ndata - 1) As Double
Dim Id As Long, Tol As Double, Info As Long, S As Double
Dim XX As Double, YY As Double, IRev As Long
'-- 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
'-- 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 integral 1/(1 + x^2) dx [0, 4] (= atan(4))
Id = 0: Tol = 0.0000000001 '1.0e-10
IRev = 0
Do
Call Pfqad_r(C(), Xi(), Lxi, K, Id, A, B, Tol, S, Info, XX, YY, IRev)
If IRev = 1 Then YY = 1
Loop While IRev <> 0
Debug.Print "S =", S, "S(true) =", Atn(4)
Debug.Print "Info =", Info
End Sub
Sub Pfqad_r(C() As Double, Xi() As Double, Lxi As Long, K As Long, Id As Long, X1 As Double, X2 As Double, Tol As Double, Quad As Double, Info As Long, XX As Double, YY As Double, IRev As Long) Integral of product of arbitrary function and PP (piecewise polynomial) form of B-spline (reverse com...
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
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
S = 1.32679961538462 S(true) = 1.32581766366803
Info = 0
|