Skip to content
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

Completes c-xsc.jl #393

Merged
merged 4 commits into from
Sep 6, 2020
Merged

Completes c-xsc.jl #393

merged 4 commits into from
Sep 6, 2020

Conversation

krish8484
Copy link
Collaborator

Added nthroot function

@coveralls
Copy link

coveralls commented Jun 22, 2020

Coverage Status

Coverage increased (+0.1%) to 90.255% when pulling 3b43a9d on krish8484:cxsc into d3a318c on JuliaIntervals:master.

@krish8484
Copy link
Collaborator Author

Had to make dummy commits since appveyor was not running on this PR. Finally, running now!

@dpsanders
Copy link
Member

Is this ready?

@krish8484
Copy link
Collaborator Author

Yes!

@@ -327,3 +328,30 @@ end
hypot(a::Interval{BigFloat}, b::Interval{BigFloat}) = sqrt(a^2 + b^2)

hypot(a::Interval{T}, b::Interval{T}) where T= atomic(Interval{T}, hypot(big53(a), big53(b)))

function nthroot(a::Interval{BigFloat}, n::Integer)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Having a docstring is always good.

b = interval(low , high)
return b
end
if n < 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like an elseif. Also the case n == 0 is absent, both from here and from the tests below.

Copy link
Collaborator Author

@krish8484 krish8484 Aug 29, 2020

Choose a reason for hiding this comment

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

Apologies, I had missed your comments, just saw them.
0th root is not defined, have added code to return empty interval

@@ -390,3 +390,30 @@ end
@test hull(v...) == II
@test hull(v) == II
end

@testset "nthroot test" begin
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add some tests for BigFloat as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added in numeric.jl

function nthroot(a::Interval{T}, n::Integer) where T
n == 1 && return a
n < 0 && a == zero(a) && return emptyinterval(a)
isempty(a) && return a
Copy link
Collaborator

Choose a reason for hiding this comment

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

The special case for n == 1, n < 0 && a == zero(a) and isempty(a) are missing in the BigFloat implementation. Any reason for that?

Also it would be good to explicitly test for them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the special case has been added for BigFloat implementation. Tests are in numeric.jl

@Kolaru
Copy link
Collaborator

Kolaru commented Sep 6, 2020

Looks good to me, thanks!

@Kolaru Kolaru merged commit a1cbb81 into JuliaIntervals:master Sep 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants