diff --git a/src/IntervalArithmetic.jl b/src/IntervalArithmetic.jl index ee372fe7f..15e978fe2 100644 --- a/src/IntervalArithmetic.jl +++ b/src/IntervalArithmetic.jl @@ -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 diff --git a/src/intervals/functions.jl b/src/intervals/functions.jl index eac8f3604..2664cb2ba 100644 --- a/src/intervals/functions.jl +++ b/src/intervals/functions.jl @@ -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)) diff --git a/test/ITF1788_tests/libieeep1788_tests_elem.jl b/test/ITF1788_tests/libieeep1788_tests_elem.jl index bd8b8095e..db03226a3 100644 --- a/test/ITF1788_tests/libieeep1788_tests_elem.jl +++ b/test/ITF1788_tests/libieeep1788_tests_elem.jl @@ -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