Skip to content

Add optional extrapolation methods #433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions src/integral_inverses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ struct LinearInterpolationIntInv{uType, tType, itpType, T} <:
extrapolation_right::ExtrapolationType.T
iguesser::Guesser{tType}
itp::itpType
function LinearInterpolationIntInv(u, t, A)
function LinearInterpolationIntInv(u, t, A, extrapolation_left = A.extrapolation_left,
extrapolation_right = A.extrapolation_right)
new{typeof(u), typeof(t), typeof(A), eltype(u)}(
u, t, A.extrapolation_left, A.extrapolation_right, Guesser(t), A)
u, t, extrapolation_left, extrapolation_right, Guesser(t), A)
end
end

Expand All @@ -57,9 +58,13 @@ function get_I(A::AbstractInterpolation)
I
end

function invert_integral(A::LinearInterpolation{<:AbstractVector{<:Number}})
function invert_integral(A::LinearInterpolation{<:AbstractVector{<:Number}},
extrapolation_left::ExtrapolationType.T = A.extrapolation_left,
extrapolation_right::ExtrapolationType.T = A.extrapolation_right)
!invertible_integral(A) && throw(IntegralNotInvertibleError())
return LinearInterpolationIntInv(A.t, get_I(A), A)

return LinearInterpolationIntInv(
A.t, get_I(A), A, extrapolation_left, extrapolation_right)
end

function _interpolate(
Expand Down Expand Up @@ -92,9 +97,11 @@ struct ConstantInterpolationIntInv{uType, tType, itpType, T} <:
extrapolation_right::ExtrapolationType.T
iguesser::Guesser{tType}
itp::itpType
function ConstantInterpolationIntInv(u, t, A)
function ConstantInterpolationIntInv(
u, t, A, extrapolation_left = A.extrapolation_left,
extrapolation_right = A.extrapolation_right)
new{typeof(u), typeof(t), typeof(A), eltype(u)}(
u, t, A.extrapolation_left, A.extrapolation_right, Guesser(t), A
u, t, extrapolation_left, extrapolation_right, Guesser(t), A
)
end
end
Expand All @@ -103,9 +110,12 @@ function invertible_integral(A::ConstantInterpolation{<:AbstractVector{<:Number}
return all(A.u .> 0)
end

function invert_integral(A::ConstantInterpolation{<:AbstractVector{<:Number}})
function invert_integral(A::ConstantInterpolation{<:AbstractVector{<:Number}},
extrapolation_left::ExtrapolationType.T = A.extrapolation_left,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function invert_integral(A::ConstantInterpolation{<:AbstractVector{<:Number}},
extrapolation_left::ExtrapolationType.T = A.extrapolation_left,
function invert_integral(
A::ConstantInterpolation{<:AbstractVector{<:Number}};
extrapolation_left::ExtrapolationType.T = A.extrapolation_left,

extrapolation_right::ExtrapolationType.T = A.extrapolation_right)
!invertible_integral(A) && throw(IntegralNotInvertibleError())
return ConstantInterpolationIntInv(A.t, get_I(A), A)
return ConstantInterpolationIntInv(
A.t, get_I(A), A, extrapolation_left, extrapolation_right)
end

function _interpolate(
Expand Down
Loading