Skip to content

Commit

Permalink
Remove some old code that is no longer required (#6)
Browse files Browse the repository at this point in the history
* Remove Compat

* Remove float(T) for rational types T, defined in Base

* Remove old buffer manipulations
  • Loading branch information
dpsanders authored Apr 9, 2017
1 parent f621c49 commit 28fde2f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/IntervalArithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ __precompile__(true)
module IntervalArithmetic

import CRlibm
using Compat
using StaticArrays
using ForwardDiff

Expand Down
2 changes: 0 additions & 2 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ end
function round_string(x::BigFloat, digits::Int, r::RoundingMode)

lng = digits + Int32(8)
# buf = Array(UInt8, lng + 1)
# @compat buf = Base.StringVector(lng + 1)
buf = Array{UInt8}(lng + 1)

lng = ccall((:mpfr_snprintf,:libmpfr), Int32,
Expand Down
15 changes: 2 additions & 13 deletions src/intervals/precision.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,13 @@ pi_interval(::Type{BigFloat}) = parameters.pi
pi_interval(::Type{Float64}) = float_interval_pi


# Rounding for rational intervals, e.g for sqrt of rational interval:
# Find the corresponding AbstractFloat type for a given rational type

Base.float{T}(::Type{Rational{T}}) = typeof(float(one(Rational{T})))

# better to just do the following ?
# Base.float(::Type{Rational{Int64}}) = Float64
# Base.float(::Type{Rational{BigInt}}) = BigFloat

# Use that type for rounding with rationals, e.g. for sqrt:

function Base.setrounding{T}(f::Function, ::Type{Rational{T}},
rounding_mode::RoundingMode)
setrounding(f, float(Rational{T}), rounding_mode)

This comment has been minimized.

Copy link
@tkelman

tkelman Apr 9, 2017

if float(::Type{Rational{T}}) isn't needed any more, then is this?

This comment has been minimized.

Copy link
@dpsanders

dpsanders Apr 9, 2017

Author Member

Yes it is, so that the following works correctly:

julia v0.5> x = Interval(1//2, 3//4);

julia v0.5> sqrt(x)
Interval(0.7071067811865475, 0.8660254037844387)

julia v0.5> x = Interval(0.5, 0.75);

julia v0.5> sqrt(x)
Interval(0.7071067811865475, 0.8660254037844387)

giving the same results.

This comment has been minimized.

Copy link
@dpsanders

dpsanders Apr 9, 2017

Author Member

Although maybe this can be achieved in other ways.

This comment has been minimized.

Copy link
@tkelman

tkelman Apr 10, 2017

It looks like Base's rounding-mode functionality doesn't extend very far beyond Float32 and Float64. Has always seemed a little fishy for this package to be using the same functions and rounding mode names to change the way other types behave. That particular case might be worth thinking about doing differently though, since if this were proposed to Base I could see there being objections to unconditionally converting from Rationals, which don't really have rounding, to floats which do.

end



float{T}(x::Interval{T}) = convert(Interval{float(T)}, x) # https://github.com/dpsanders/IntervalArithmetic.jl/issues/174
float{T}(x::Interval{T}) = convert( Interval{float(T)}, x) # https://github.com/dpsanders/IntervalArithmetic.jl/issues/174

big{T}(x::Interval{T}) = convert(Interval{BigFloat}, x)
big(x::Interval) = convert(Interval{BigFloat}, x)

0 comments on commit 28fde2f

Please sign in to comment.