Skip to content

Commit

Permalink
Apply extrapolation options to all interpolation types
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Nov 14, 2024
1 parent f0efd0e commit 154b755
Show file tree
Hide file tree
Showing 6 changed files with 368 additions and 178 deletions.
6 changes: 4 additions & 2 deletions src/derivatives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function _extrapolate_derivative_down(A, t, order)
typed_zero
elseif extrapolation_down == ExtrapolationType.linear
(order == 1) ? derivative(A, first(A.t)) : typed_zero
elseif extrapolation_down == ExtrapolationType.extension
else
# extrapolation_down == ExtrapolationType.extension
iguess = A.iguesser
(order == 1) ? _derivative(A, t, iguess) :
ForwardDiff.derivative(t -> begin
Expand All @@ -40,7 +41,8 @@ function _extrapolate_derivative_up(A, t, order)
typed_zero
elseif extrapolation_up == ExtrapolationType.linear
(order == 1) ? derivative(A, last(A.t)) : typed_zero
elseif extrapolation_up == ExtrapolationType.extension
else
# extrapolation_up == ExtrapolationType.extension
iguess = A.iguesser
(order == 1) ? _derivative(A, t, iguess) :
ForwardDiff.derivative(t -> begin
Expand Down
6 changes: 3 additions & 3 deletions src/integrals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function _extrapolate_integral_down(A, idx, t)
elseif extrapolation_down == ExtrapolationType.linear
slope = derivative(A, first(A.t))
Δt = t - first(A.t)
(first(A.u) + slope * Δt/2) * Δt
(first(A.u) + slope * Δt / 2) * Δt
elseif extrapolation_down == ExtrapolationType.extension
_integral(A, idx, t)
end
Expand All @@ -61,11 +61,11 @@ function _extrapolate_integral_up(A, idx, t)
if extrapolation_up == ExtrapolationType.none
throw(UpExtrapolationError())
elseif extrapolation_up == ExtrapolationType.constant
integral(A, A.t[end-1], A.t[end]) + last(A.u) * (t - last(A.t))
integral(A, A.t[end - 1], A.t[end]) + last(A.u) * (t - last(A.t))
elseif extrapolation_up == ExtrapolationType.linear
slope = derivative(A, last(A.t))
Δt = t - last(A.t)
integral(A, A.t[end-1], A.t[end]) + (last(A.u) + slope * Δt/2) * Δt
integral(A, A.t[end - 1], A.t[end]) + (last(A.u) + slope * Δt / 2) * Δt
elseif extrapolation_up == ExtrapolationType.extension
_integral(A, idx, t)
end
Expand Down
Loading

0 comments on commit 154b755

Please sign in to comment.