Skip to content

Commit

Permalink
Merge 5b302fb into 1516c5e
Browse files Browse the repository at this point in the history
  • Loading branch information
yashrajgupta committed Aug 21, 2019
2 parents 1516c5e + 5b302fb commit d101f0e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/IntervalArithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export
midpoint_radius, interval_from_midpoint_radius,
RoundTiesToEven, RoundTiesToAway,
cancelminus, cancelplus, isunbounded,
.., @I_str, ±,
.., @I_str, ±, reciprocal_sqrt,
pow, extended_div,
setformat, @format

Expand Down
9 changes: 9 additions & 0 deletions src/intervals/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,12 @@ for f in (:log, :log2, :log10, :log1p)

end
end

#computes the reciprocal of square root of an Interval
function reciprocal_sqrt(a::Interval{T}) where T
x = sqrt(a)
isempty(x) && return emptyinterval(x)
x.lo == zero(T) < x.hi && return @round(inv(x.hi), T(Inf))
x == zero(x) && return emptyinterval(T)
@round(inv(x.hi), inv(x.lo))
end
14 changes: 14 additions & 0 deletions test/ITF1788_tests/libieeep1788_tests_elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,20 @@ end
@test decoration((DecoratedInterval(Interval(-5.0, Inf), dac))^(1//2)) == decoration(DecoratedInterval(Interval(0.0, Inf), trv))
end

@testset "minimal_rsqrt_test" begin
@test reciprocal_sqrt(∅) == ∅
@test reciprocal_sqrt(Interval(-Inf, Inf)) == 0 .. Inf
@test reciprocal_sqrt(Interval(-Inf, -0x0.0000000000001p-1022)) == ∅
@test reciprocal_sqrt(Interval(-1.0, 1.0)) == 1.0 .. Inf
@test reciprocal_sqrt(Interval(0.0, 1.0)) == 1.0 .. Inf
@test reciprocal_sqrt(Interval(-0.0, 1.0)) == 1.0 .. Inf
@test reciprocal_sqrt(Interval(-5.0, 25.0)) == 0.2 .. Inf
@test reciprocal_sqrt(Interval(0.0, 25.0)) == 0.2 .. Inf
@test reciprocal_sqrt(Interval(-0.0, 25.0)) == 0.2 .. Inf
@test reciprocal_sqrt(Interval(-5.0, Inf)) == 0.0 .. Inf
@test reciprocal_sqrt(Interval(4.0, 25.0)) == 0.2 .. 0.5
end

@testset "minimal_fma_test" begin
@test fma(∅, ∅, ∅) == ∅
@test fma(Interval(-1.0, 1.0), ∅, ∅) == ∅
Expand Down

0 comments on commit d101f0e

Please sign in to comment.