Skip to content

Commit

Permalink
Allow twopoint to be a Val
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 2, 2023
1 parent d08f3f7 commit a12a4fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/problems/bvp_problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,17 @@ end
# But we need it for function calls like TwoPointBVProblem{iip}(...) = ...
struct TwoPointBVPFunction{iip} end

@inline TwoPointBVPFunction(args...; kwargs...) = BVPFunction(args...; kwargs..., twopoint=true)
@inline function TwoPointBVPFunction(args...; kwargs...)
return BVPFunction(args...; kwargs..., twopoint = Val(true))
end
@inline function TwoPointBVPFunction{iip}(args...; kwargs...) where {iip}
return BVPFunction{iip}(args...; kwargs..., twopoint=true)
return BVPFunction{iip}(args...; kwargs..., twopoint = Val(true))
end

function TwoPointBVProblem{iip}(f, bc, u0, tspan, p = NullParameters();
bcresid_prototype=nothing, kwargs...) where {iip}
return TwoPointBVProblem(TwoPointBVPFunction{iip}(f, bc; bcresid_prototype), u0, tspan, p;
kwargs...)
return TwoPointBVProblem(TwoPointBVPFunction{iip}(f, bc; bcresid_prototype), u0, tspan,
p; kwargs...)
end
function TwoPointBVProblem(f, bc, u0, tspan, p = NullParameters();
bcresid_prototype=nothing, kwargs...)
Expand Down
9 changes: 5 additions & 4 deletions src/scimlfunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4064,12 +4064,13 @@ function BVPFunction{iip, specialize, twopoint}(f, bc;
end
end

function BVPFunction{iip}(f, bc; twopoint::Bool=false, kwargs...) where {iip}
BVPFunction{iip, FullSpecialize, twopoint}(f, bc; kwargs...)
function BVPFunction{iip}(f, bc; twopoint::Union{Val, Bool}=Val(false),
kwargs...) where {iip}
BVPFunction{iip, FullSpecialize, _unwrap_val(twopoint)}(f, bc; kwargs...)
end
BVPFunction{iip}(f::BVPFunction, bc; kwargs...) where {iip} = f
function BVPFunction(f, bc; twopoint::Bool=false, kwargs...)
BVPFunction{isinplace(f, 4), FullSpecialize, twopoint}(f, bc; kwargs...)
function BVPFunction(f, bc; twopoint::Union{Val, Bool}=Val(false), kwargs...)
BVPFunction{isinplace(f, 4), FullSpecialize, _unwrap_val(twopoint)}(f, bc; kwargs...)
end
BVPFunction(f::BVPFunction; kwargs...) = f

Expand Down

0 comments on commit a12a4fc

Please sign in to comment.