diff --git a/Project.toml b/Project.toml index e9b8bb6d5..8df0c7368 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "IntervalArithmetic" uuid = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253" repo = "https://github.com/JuliaIntervals/IntervalArithmetic.jl.git" -version = "0.20.4" +version = "0.20.5" [deps] CRlibm = "96374032-68de-5a5b-8d9e-752f78720389" diff --git a/src/intervals/arithmetic.jl b/src/intervals/arithmetic.jl index e467e1c0c..7a7f61b2a 100644 --- a/src/intervals/arithmetic.jl +++ b/src/intervals/arithmetic.jl @@ -305,6 +305,8 @@ end inf(a::Interval) = ifelse(iszero(a.lo) && !signbit(a.lo), copysign(a.lo, -1), a.lo) sup(a::Interval) = a.hi +inf(a::Real) = a +sup(a::Real) = a ## Functions needed for generic linear algebra routines to work real(a::Interval) = a @@ -512,6 +514,10 @@ function radius(a::Interval{Rational{T}}) where T return max(m - a.lo, a.hi - m) end +mid(a::Real) = a +diam(a::Real) = zero(a) +radius(a::Real) = zero(a) + # cancelplus and cancelminus """ cancelminus(a, b) diff --git a/test/interval_tests/consistency.jl b/test/interval_tests/consistency.jl index 2f3fc192f..b4328784c 100644 --- a/test/interval_tests/consistency.jl +++ b/test/interval_tests/consistency.jl @@ -186,6 +186,9 @@ setprecision(Interval, Float64) @test inf(entireinterval(a)) == -Inf @test sup(entireinterval(a)) == Inf @test isnan(sup(nai(BigFloat))) + + @test inf(2.5) == 2.5 + @test sup(2.5) == 2.5 end @testset "mid" begin @@ -220,6 +223,8 @@ setprecision(Interval, Float64) @test diam( @interval(0.1) ) == eps(0.1) @test isnan(diam(emptyinterval())) @test diam(a) == 1.0000000000000002 + + @test diam(0.1) == 0 end @testset "mig and mag" begin @@ -286,6 +291,9 @@ setprecision(Interval, Float64) else @test_throws InexactError nai(Interval(1//2)) end + + @test mid(2.125) == 2.125 + @test radius(2.125) == 0 end @testset "abs, min, max, sign" begin