Interface AbstractHermiteSpline

The AbstractHermiteSpline defines an interface to cubic Hermite splines with various possible implementations.

Base.append!Method
append!(r::H, s::H)    # H<:AbstractHermiteSpline

Concatenate Hermite splines r and s by appending all knots, values and derivative of s to r.

precondition

The knot sequences of s and t must be compatible (ismonotone). If knots last(s) and first(r) are identical and their values and derivatives coincide, the first knot of s is ignored and will not be append.

See also vcat

source
Base.copy!Method
copy(hdst::H, h::H) # where {H<:AbstractHermiteSpline}

Deep copy of h into hdst

source
Base.copyMethod
hc = copy(h::AbstractHermiteSpline)

Get (deep) copy of h.

source
Base.reverse!Method
reverse!(h::AbstractHermiteSpline)

Reverse knot vector and coefficient vector(s).

source
Base.reverseMethod
hr = reverse!(h::AbstractHermiteSpline)

Copy h with reversed knot vector and coefficient vector(s).

source
Base.similarMethod
similar(h::AbstractHermiteSpline)

Get empty spline of tyepof(h).

source
Base.vcatMethod
vcat(s::H, r::H, ...)    # H<:AbstractHermiteSpline

Construct a new Hermite spline by concatenating r, s, ....

precondition

Same requirements as for append!!

See also append!

source
HermiteSpline.boundedindexMethod
i = boundedindex(h::AbstractHermiteSpline, t, [lo = 1])

Find index of knot interval for parameter t. Returns the index of the first or last knot interval if t < first(h) or t > last(h), respectvely, for extrapolation.

Note

The result is undefined if isempty

See also index

source
HermiteSpline.hermitesplineFunction

Empty spline

s = hermitespline(n, type[, impl = :t_xdx])
s = hermitespline(Val(n), type, Val(impl))
s = hermitespline(SVector{n, type}[, impl = :t_xdx])

Construct empty Hermite spline with scalar knot type and n-vectors (SVector{n, type}) for values and derivatives. To "fill" data use, e.g., push! or append!

The implementation defines the storage layout. Possible values are :t_x_dx, :t_xdx and :txdx, where speration by "_" indicates use of a Vector (e.g., for :t_x_dx one for knots, values and derivatives).

Note

For n==1, i.e., scalar values and derivatives, values and derivatives are stored as scalars of type (not SVector{1, type}).

Spline from data:

s = hermitespline(t, x, dx[, impl = :t_x_dx])
s = hermitespline(t, xdx[, impl = :t_xdx])
s = hermitespline(txdx[, impl = :txdx])

Construct Hermite spline from knots t, values x and derivatives dx or vectors of tuples.

precondition
  1. The passed vectors must have equal length.
  2. The passed vectors are for exclusive use by hermitespline, the constructor doesn't copy!

See also AbstractHermiteSpline

source
HermiteSpline.indexMethod
i = index(h::AbstractHermiteSpline, t[, lo=1])

Find index of knot interval for parameter t.

The optional argument lo defines the initial lower (left) bound for the binary serach, which must be a valid index!

Note

The method returns an invalid index (0 or length(h)) if t ∉ span(h). This method is intended for internal use.

See also piece, boundedindex

source
HermiteSpline.isindexMethod
isindex(h::AbstractHermiteSpline, i, t)

Is i a valid index for h such that t is within the i-th knot interval?

Note

Returns false if t < first(s) or last(s) < t (extrapolation).

See also index

source
HermiteSpline.ismonotoneFunction
ismonotone(h::AbstractHermiteSpline)

Test if knot sequence is strictly monotone. This method iterates over all knots and is intended for (internal) checks.

Note

Returns true if isempty

ismonotone(h::AbstractHermiteSpline, t)

Test if t could be added to the knot sequence such that the sequence is still (strictly) monotone. This method is is called by push!

Note

Returns true if isempty, returns false if t == last(h) (zero length knot interval).

See also push!

source
HermiteSpline.pieceFunction
p = piece(h::AbstractHermiteSpline, i::Int)
p = piece(h::AbstractHermiteSpline, t[, i::Int])

Get HermitePiece for evaluation from index i or parameter t. No search if t is within i-th interval.

Note
  • Requires not isempty(h).
  • For indices, requires 1 <= i < length(h).
  • For parameters, computes index but returns the first or last piece if t ∉ span(h).
source
HermiteSpline.spanMethod
t0, t1 = span(h::AbstractHermiteSpline)

Get first and last knot. They determine the parameter interval of h.

Note

The spline can certainly extrapolated beyond t0 or t1. Note, however, that extrapolaiton is numerically unstable if the parameter is too far w.r.t. the length of the knot interval (evaluation of monomials away from $[0, 1]$).

source
HermiteSpline.evFunction
(x, dx), idx = ev(h, t, ValueDerivative, idx)  # value and derivative
x, dx = ev(h, t, ValueDerivative)
x_dx = collect(ev(h, range(t0, t1, length=n))) #   from generator
x_dx = ev(h, ts::Vector, ValueDerivative[; issorted=false])

x, idx = ev(h, t, Value, idx)                  # value only
x = ev(h, t, Value)
x = collect(ev(h, range(t0, t1, length=n)))    #   from generator
x = ev(h, ts::Vector, Value[; issorted=false])

Evaluate AbstractHermiteSpline h(t), provide (possibly reused) knot interval index idx from previous evaluation. Compute value and derivative (x, dx) or only value x.

The evaluation at parameters ts in a Vector is more efficient if ts is sorted (w.r.t isascending) due to use of caches and because the current index is stored for lookup. However, sorting ts exclusively for a single pass of evaluation may be more expensive than point-location tests for an unsorted ts.

  • If sorted = false is passed, the ev sorts enforces sorting ts before evaluation (if ts are not already sorted). The returned values apprear in the order of ts as for input (i.e., in addition to sort! there is an extra overhead for using sortperm! and applying the permutation).
  • If sorted = true is passed, ev evaluates at parameters ts without assumptions on order.
Note

Passing sorted = true is not an assertion that parameters ts are sorted but rather a hint that ev shall not perform any sorting.

Alternative syntax

AbstractHermiteSpline h is a callable object, which delegates arguments to ev(h, t, ...).

output = h(t, ...)                            # output: see above
x = h(t)                                      # default: value only
source