XLPack 6.1
Julia API Reference Manual
Loading...
Searching...
No Matches

◆ pchse()

function pchse ( n::Integer  ,
x::Array{Float64}  ,
f::Array{Float64}  ,
d::Array{Float64}  ,
incfd::Integer  = 1 
)

Piecewise cubic spline interpolation ("not a knot" condition)

Purpose
pchse computes the derivatives needed to determine the Hermite representation of the cubic spline interpolant to given data, with with the default boundary conditions ("not a knot" condition).

The resulting piecewise cubic spline function may be evaluated by pchfe or pchfd.
Returns
info (Int32)
= 0: Successful exit
= -1: The argument n had an illegal value (n < 2)
= -2: The argument x is invalid (e.g. not strictly increasing)
= -3: The argument f is invalid
= -4: The argument d is invalid
= -5: The argument incfd had an illegal value (incfd < 1)
Parameters
[in]nNumber of data points. (n >= 2)
[in]x1-dimensional array (Float64, n)
Independent variable values. The elements of x[] must be strictly increasing.
[in]f1-dimensional array (Float64, incfd*(n - 1) + 1)
Dependent variable values to be interpolated. f[i*incfd] is the value corresponding to x[i] (i = 0 to n - 1).
[out]d1-dimensional array (Float64, incfd*(n - 1) + 1)
Derivative values at the data points. These values will determine the cubic spline interpolant with the requested boundary conditions. The value corresponding to x[i] is stored in d[i*incfd] (i = 0 to n - 1). No other entries in d are changed.
[in]incfd(Optional)
Increment between successive values in f and d. This argument is provided primarily for 2-D applications. (incfd >= 1) (default = 1)
Reference
SLATEC (PCHIP) (Driver for pchsp)
Example Program
Compute ln(0.115) and ln(0.125) by interpolating the following natural logarithm table with cubic spline.
  x       ln(x)
------ ---------
 0.10   -2.3026
 0.11   -2.2073
 0.12   -2.1203
 0.13   -2.0402
------ ---------
function TestPchse()
n = 4
x = [ 0.1, 0.11, 0.12, 0.13 ]
y = [ -2.3026, -2.2073, -2.1203, -2.0402 ]
d = Vector{Cdouble}(undef, n)
info = pchse(n, x, y, d)
println(info)
if info == 0
ne = 2
xe = [ 0.115, 0.125 ]
ye = Vector{Cdouble}(undef, ne)
info = pchfe(n, x, y, d, ne, xe, ye)
println(ye)
println(info)
end
end
function pchfe(n::Integer, x::Array{Float64}, f::Array{Float64}, d::Array{Float64}, ne::Integer, xe::Array{Float64}, fe::Array{Float64}, incfd::Integer=1, skip::Bool(keyword argument)=false)
Evaluation of function values for piecewise cubic Hermite (and cubic spline) interpolation
function pchse(n::Integer, x::Array{Float64}, f::Array{Float64}, d::Array{Float64}, incfd::Integer=1)
Piecewise cubic spline interpolation ("not a knot" condition)
Example Results
> TestPchse()
0
[-2.1628499999999997, -2.079475]
0