Skip to content

Commit

Permalink
Add smooth derivative for last point of Akima Fixes #119
Browse files Browse the repository at this point in the history
  • Loading branch information
GlenHertz authored Jun 30, 2022
1 parent 1dbd529 commit d4031bd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/derivatives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,12 @@ function derivative(A::LagrangeInterpolation{<:AbstractMatrix}, t::Number)
end

function derivative(A::AkimaInterpolation{<:AbstractVector}, t::Number)
t < A.t[1] && return zero(A.u[1])
t > A.t[end] && return zero(A.u[end])
i = searchsortedlast(A.t, t)
i == 0 && return zero(A.u[1])
i == length(A.t) && return zero(A.u[end])
j = min(i, length(A.c)) # for smooth derivative at A.t[end]
wj = t - A.t[i]
@evalpoly wj A.b[i] 2A.c[i] 3A.d[i]
@evalpoly wj A.b[i] 2A.c[j] 3A.d[j]
end

function derivative(A::ConstantInterpolation{<:AbstractVector}, t::Number)
Expand Down

0 comments on commit d4031bd

Please sign in to comment.