Skip to content

Commit

Permalink
Change name of rsqrt function and add doc string
Browse files Browse the repository at this point in the history
  • Loading branch information
yashrajgupta committed Aug 21, 2019
1 parent 0b4f8c3 commit 5b302fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
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, ±, rsqrt,
.., @I_str, ±, reciprocal_sqrt,
pow, extended_div,
setformat, @format

Expand Down
3 changes: 2 additions & 1 deletion src/intervals/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ for f in (:log, :log2, :log10, :log1p)
end
end

function rsqrt(a::Interval{T}) where T
#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))
Expand Down
22 changes: 11 additions & 11 deletions test/ITF1788_tests/libieeep1788_tests_elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -996,17 +996,17 @@ end
end

@testset "minimal_rsqrt_test" begin
@test rsqrt(∅) == ∅
@test rsqrt(Interval(-Inf, Inf)) == 0 .. Inf
@test rsqrt(Interval(-Inf, -0x0.0000000000001p-1022)) == ∅
@test rsqrt(Interval(-1.0, 1.0)) == 1.0 .. Inf
@test rsqrt(Interval(0.0, 1.0)) == 1.0 .. Inf
@test rsqrt(Interval(-0.0, 1.0)) == 1.0 .. Inf
@test rsqrt(Interval(-5.0, 25.0)) == 0.2 .. Inf
@test rsqrt(Interval(0.0, 25.0)) == 0.2 .. Inf
@test rsqrt(Interval(-0.0, 25.0)) == 0.2 .. Inf
@test rsqrt(Interval(-5.0, Inf)) == 0.0 .. Inf
@test rsqrt(Interval(4.0, 25.0)) == 0.2 .. 0.5
@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
Expand Down

0 comments on commit 5b302fb

Please sign in to comment.