Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierHnt committed Oct 1, 2023
1 parent 07cfd38 commit 747a2cf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
58 changes: 29 additions & 29 deletions src/IntervalArithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Base:
rad2deg, deg2rad,
sin, cos, tan, cot, csc, sec, asin, acos, atan, acot, sinpi, cospi, sincospi,
sinh, cosh, tanh, coth, csch, sech, asinh, acosh, atanh, acoth,
convert,
float, big,
floor, ceil, trunc, sign, round, copysign, flipsign, signbit,
expm1, log1p,
Expand All @@ -27,50 +26,51 @@ import Base:
import Base.MPFR: MPFRRoundingMode
import Base.MPFR: MPFRRoundUp, MPFRRoundDown, MPFRRoundNearest, MPFRRoundToZero, MPFRRoundFromZero

export
Interval, interval, ±, @I_str,
diam, radius, mid, midradius, scaled_mid, mag, mig, hull,
emptyinterval, isemptyinterval,
ismember, intersectinterval, isweakinterior, isstrictinterior,
isdisjointinterval, setdiffinterval,
weakprecedes, strictprecedes, contains_zero, isthinzero, isweakless, isstrictless,
overlap, Overlap,
isequalinterval,
entireinterval, isentireinterval, nai, isnai, isthin, iscommon, isatomic,
inf, sup, bounds, bisect, mince,
dist,
RoundTiesToEven, RoundTiesToAway,
IntervalRounding,
cancelminus, cancelplus, isbounded, isunbounded,
pow, extended_div, nthroot,
setformat

## Decorations
export
decoration, DecoratedInterval,
com, dac, def, trv, ill



function __init__()
setrounding(BigFloat, RoundNearest)
end

function Base.setrounding(f::Function, ::Type{Rational{T}},
rounding_mode::RoundingMode) where T
function Base.setrounding(f::Function, ::Type{Rational{T}}, rounding_mode::RoundingMode) where {T<:Integer}
return setrounding(f, float(Rational{T}), rounding_mode)
end

## Includes
#

include("intervals/intervals.jl")
export Interval, interval, ±, @I_str,
diam, radius, mid, midradius, scaled_mid, mag, mig, hull,
emptyinterval, isemptyinterval,
isequalinterval,
ismember,
isweakinterior, isstrictinterior,
weakprecedes, strictprecedes,
isweakless, isstrictless,
contains_zero,
isthinzero, isthin,
isbounded, isunbounded,
isdisjointinterval, intersectinterval, setdiffinterval,
entireinterval, isentireinterval, nai, isnai, iscommon, isatomic,
inf, sup, bounds, mince,
dist,
RoundTiesToEven, RoundTiesToAway,
IntervalRounding,
cancelminus, cancelplus,
pow, extended_div, nthroot,
overlap, Overlap

include("bisect.jl")
export bisect

include("decorations/decorations.jl")
export decoration, DecoratedInterval, com, dac, def, trv, ill

include("rand.jl")

include("parsing.jl")

include("display.jl")
export setformat

include("symbols.jl")

end
10 changes: 5 additions & 5 deletions src/intervals/rounding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ const rounding_types = (:fast, :tight, :accurate, :slow, :none)
interval_rounding() = IntervalRounding{:tight}()

# BigFloat conversion
convert(::Type{BigFloat}, x, rounding_mode::RoundingMode) =
setrounding(BigFloat, rounding_mode) do
convert(BigFloat, x)
end
# convert(::Type{BigFloat}, x, rounding_mode::RoundingMode) =
# setrounding(BigFloat, rounding_mode) do
# convert(BigFloat, x)
# end

# Parsing from string
parse(::Type{T}, x::AbstractString, rounding_mode::RoundingMode) where T = setrounding(Float64, rounding_mode) do
Expand Down Expand Up @@ -230,4 +230,4 @@ for f in (:+, :-, :*, :/, :^, :atan)
@eval function $f(::IntervalRounding{:none}, a, b, r::RoundingMode)
return $f(a, b)
end
end
end

0 comments on commit 747a2cf

Please sign in to comment.