support for clamp and min, max, clamp with ForwardDiff#642
Open
smkatz12 wants to merge 1 commit intoJuliaIntervals:masterfrom
Open
support for clamp and min, max, clamp with ForwardDiff#642smkatz12 wants to merge 1 commit intoJuliaIntervals:masterfrom
smkatz12 wants to merge 1 commit intoJuliaIntervals:masterfrom
Conversation
OlivierHnt
reviewed
May 16, 2024
| function Base.$f(x::BareInterval{T}, y::Rational) where {T<:NumTypes} | ||
| isempty_interval(x) && return x | ||
| return _unsafe_bareinterval(T, $f(inf(x), y), $f(sup(x), y)) | ||
| end |
Member
There was a problem hiding this comment.
We purposely do not allow functions mixing BareInterval and Number in their computations, because BareInterval cannot keep track of guarantees ("NG" flag)or decorations.
So my first impulse here would be not to define such function.
OlivierHnt
reviewed
May 16, 2024
| return _unsafe_bareinterval(T, $f(inf(x), y), $f(sup(x), y)) | ||
| end | ||
| Base.$f(x::BareInterval, y::BareInterval) = $f(promote(x, y)...) | ||
| Base.$f(x::BareInterval, y::Rational) = $f(promote(x), y) |
OlivierHnt
reviewed
May 16, 2024
| d = decoration(x) | ||
| return _unsafe_interval(r, d, false) | ||
| end | ||
| Base.$f(x::Rational, y::Interval) = $f(y, x) |
Member
There was a problem hiding this comment.
On the latest version of IntervalArithmetic.jl, min and max already do this ; so defining these functions is maybe superfluous here ? Or am I missing something ?
Member
|
Thx for opening the PR! I have to think a bit more about the decoration requirement. This may be a little more subtle. @Kolaru don't you think we will run into the same issue as we did with the derivative of |
Member
|
In term of decorations, for consistency we must have:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on the discussion in #640, we (@mossr, @ancorso, @mykelk) have implemented the following:
minandmaxwhen one input is an interval and the other is a floatclampmin,max, andclampwhen computing first and second derivatives with ForwardDiff