diff --git a/src/intervals/interval_operations/numeric.jl b/src/intervals/interval_operations/numeric.jl index 87566fa6b..2533e1719 100644 --- a/src/intervals/interval_operations/numeric.jl +++ b/src/intervals/interval_operations/numeric.jl @@ -26,7 +26,7 @@ function inf(x::Interval{<:Rational}) return inf(bareinterval(x)) end -inf(x::Real) = inf(x) +inf(x::Real) = x """ sup(x) @@ -50,7 +50,7 @@ function sup(x::Interval{<:Rational}) return sup(bareinterval(x)) end -sup(x::Real) = sup(x) +sup(x::Real) = x """ bounds(x) @@ -73,7 +73,7 @@ function bounds(x::Interval{<:Rational}) return bounds(bareinterval(x)) end -bounds(x::Real) = bounds(x) +bounds(x::Real) = (x, x) """ mid(x) @@ -121,7 +121,7 @@ function mid(x::Interval{<:Rational}) return mid(bareinterval(x)) end -mid(x::Real) = mid(interval(x)) +mid(x::Real) = x mid(x::Complex) = complex(mid(real(x)), mid(imag(x))) """ @@ -175,7 +175,7 @@ function scaled_mid(x::Interval{<:Rational}, α::Real) return scaled_mid(bareinterval(x), α) end -scaled_mid(x::Real, α::Real) = scaled_mid(interval(x), α) +scaled_mid(x::Real, ::Real) = x scaled_mid(x::Complex, α::Real) = complex(scaled_mid(real(x), α), scaled_mid(imag(x), α)) """ @@ -207,7 +207,7 @@ function diam(x::Interval{<:Rational}) return diam(bareinterval(x)) end -diam(x::Real) = diam(interval(x)) +diam(x::Real) = zero(x) diam(x::Complex) = max(diam(real(x)), diam(imag(x))) """ @@ -236,7 +236,7 @@ function radius(x::Interval{<:Rational}) return radius(bareinterval(x)) end -radius(x::Real) = radius(interval(x)) +radius(x::Real) = zero(x) radius(x::Complex) = max(radius(real(x)), radius(imag(x))) """ @@ -264,7 +264,7 @@ function midradius(x::Interval{<:Rational}) return midradius(bareinterval(x)) end -midradius(x::Real) = midradius(interval(x)) +midradius(x::Real) = (mid(x), radius(x)) midradius(x::Complex) = (mid(x), radius(x)) """ @@ -294,8 +294,8 @@ function mag(x::Interval{<:Rational}) return mag(bareinterval(x)) end -mag(x::Real) = mag(interval(x)) -mag(x::Complex) = mag(interval(x)) +mag(x::Real) = abs(x) +mag(x::Complex) = max(mag(real(x)), mag(imag(x))) """ mig(x) @@ -326,8 +326,8 @@ function mig(x::Interval{<:Rational}) return mig(bareinterval(x)) end -mig(x::Real) = mig(interval(x)) -mig(x::Complex) = mig(interval(x)) +mig(x::Real) = abs(x) +mig(x::Complex) = min(mag(real(x)), mag(imag(x))) """ dist(x, y)