Skip to content

Commit

Permalink
update isapprox
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreySarnoff committed Apr 9, 2020
1 parent 6b2b152 commit 1bb8889
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/extras/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,18 @@ releps(::Type{Float32}) = ldexp(inv(sqrt(2.0f0)), -17)
releps(::Type{Double64}) = ldexp(0.5, -62)
releps(::Type{Double32}) = ldexp(inv(sqrt(2.0f0)), -34)

#=
function isapprox(x::Number, y::Number; atol::Real=0, rtol::Real=rtoldefault(x,y,atol), nans::Bool=false)
x == y || (isfinite(x) && isfinite(y) && abs(x-y) <= max(atol, rtol*max(abs(x), abs(y)))) || (nans && isnan(x) && isnan(y))
end
function Base.isapprox(x::DoubleFloat{T}, y::T; atol::Real=0.0, rtol::Real=atol>0 ? 0 : releps(T), nans::Bool=false, norm::Function=norm) where {T<:IEEEFloat}
return isapprox(x, DoubleFloat{T}(y), atol=atol, rtol=rtol, nans=nans, norm=norm)
function Base.isapprox(x::DoubleFloat{T}, y::Real; atol::Real=0.0, rtol::Real=Base.rtoldefault(HI(x),y,atol), nans::Bool=false) where {T<:IEEEFloat}
return isapprox(x, DoubleFloat{T}(y), atol=atol, rtol=rtol, nans=nans)
end
function Base.isapprox(x::T, y::DoubleFloat{T}; atol::Real=0.0, rtol::Real=atol>0 ? 0 : releps(T), nans::Bool=false, norm::Function=norm) where {T<:IEEEFloat}
return isapprox(DoubleFloat{T}(x), y, atol=atol, rtol=rtol, nans=nans, norm=norm)
function Base.isapprox(x::Real, y::DoubleFloat{T}; atol::Real=0.0, rtol::Real=Base.rtoldefault(x,HI(y),atol), nans::Bool=false) where {T<:IEEEFloat}
return isapprox(DoubleFloat{T}(x), y, atol=atol, rtol=rtol, nans=nans)
end
function Base.isapprox(x::DoubleFloat{T}, y::DoubleFloat{T}; atol::Real=0.0, rtol::Real=atol>0 ? 0 : releps(DoubleFloat{T}), nans::Bool=false, norm::Function=norm) where {T<:IEEEFloat}
x == y || (isfinite(x) && isfinite(y) && abs(x-y) <= max(max(1.0e-32, atol), rtol*max(abs(x), abs(y)))) || (nans && isnan(x) && isnan(y))
function Base.isapprox(x::DoubleFloat{T}, y::DoubleFloat{T}; atol::Real=0.0, rtol::Real=Base.rtoldefault(HI(x),HI(y),atol), nans::Bool=false) where {T<:IEEEFloat}
HI(x) === HI(y) || (isfinite(x) && isfinite(y) && abs(x-y) <= max(max(1.0e-32, atol), rtol*max(abs(x), abs(y)))) || (nans && isnan(x) && isnan(y))
end
Base.isapprox(x::DoubleFloat{T}, y::F; atol::Real=0.0, rtol::Real=atol>0.0 ? 0.0 : eps(max(abs(x), abs(y)))^(37/64), nans::Bool=false, norm::Function=norm) where {T<:IEEEFloat, F<:Real} =
Base.isapprox(x::DoubleFloat{T}, y::DoubleFloat{F}; atol::Real=0.0, rtol::Real=Base.rtoldefault(HI(x),HI(y),atol), nans::Bool=false) where {T<:IEEEFloat, F<:IEEEFloat} =
isapprox(promote(x, y)..., atol=atol, rtol=rtol, nans=nans, norm=norm)

Base.isapprox(x::F, y::DoubleFloat{T}; atol::Real=0.0, rtol::Real=atol>0.0 ? 0.0 : eps(max(abs(x), abs(y)))^(37/64), nans::Bool=false, norm::Function=norm) where {T<:IEEEFloat, F<:Real} =
isapprox(promote(x, y)..., atol=atol, rtol=rtol, nans=nans, norm=norm)
=#

function Base.lerpi(j::Integer, d::Integer, a::DoubleFloat{T}, b::DoubleFloat{T}) where {T}
t = DoubleFloat{T}(j)/d
a = fma(-t, a, a)
Expand Down

4 comments on commit 1bb8889

@JeffreySarnoff
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error while trying to register: Action not recognized: Register

@JeffreySarnoff
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/12615

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.7 -m "<description of version>" 1bb88891c77ed1d4bda205e2a839d32be5e98a69
git push origin v1.1.7

Please sign in to comment.