-
Notifications
You must be signed in to change notification settings - Fork 71
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
Simplified version of mod(x::Interval, y::Real) #525
Merged
Merged
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fea1b34
Introduce simplified version of mod
petvana 153d749
Improve testing
petvana d23df89
Update src/intervals/functions.jl
petvana b56f4be
Use ⊇ operator
petvana ea00b23
Imrpove test coverage + use zero()
petvana ff47910
Add todo for mod with between two intervals
petvana 45abc46
Implementation for strictly negative divisors for mod
petvana d2603d6
Update docs
petvana 439723f
Disable divisor for mod to be an interval
petvana 6fdc809
Merge branch 'simplified-mod' of github.com:petvana/IntervalArithmeti…
petvana f9f4733
Throw ArgumentError for Interval divisor for mod
petvana 7bef23e
Cleanup
petvana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to extend this to have strictly negative
y
? I understand that having0 ∈ y
complicates things....There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated for strictly negative divisor. Hope its correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation seems to me correct if we have
y::AbstractFloat
(perhaps also including Rationals, but let me forget about them now), which corresponds to the tests.However, if
y::Interval
(and we haveInterval <: Real
) then there this function throws errors: e.g., trymod(1..2, 1..2)
, which I think should returnInterval(0.0, 2.0)
. In this case things are subtle, becausey != zero(y)
is true for[-1, 1]
, but that interval is not strictly positive or negative. Also,Interval(zero(y), y)
causes the error mentioned above. I guess this is the reason thatmod
has two methods in #178.My suggestion is either restrict
y::AbstractFloat
, or include a new method wherey::Interval
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my mistake. My intention was to constrain
y
NOT to beInterval
. I've not realized1..3 isa Real -> true
. However, If I constraint it toy::AbstractFloat
it does not accept integers for example because1 isa AbstractFloat -> false
, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could do
Union{AbstractFloat, Integer}
to accept both integers and floats but no intervals (similar to add rationals and irrationals).Can the method be generalized to the case of
y
interval?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually forget about the union, a better suggestion would be to define
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mod
can indeed be generalized fory::Interval
. It's tricky with respect of having zero within the interval, which is part of the reason I was suggesting to have either a strictly positive or negativey
. Actually, a motivating example would be to havey::Irrational
, or actually any (mathematical) real number which is not exactly representable as aFloat64
. Note that #178 includes such an implementation, though it does not include the restriction of strictly positive/negative intervals. The subtleties related to zero at the end are related to the division:y
appears in the denominator.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I unresolved this conversation, so it is easy to track the discussion...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw in octave