Skip to content

Commit 4b9142b

Browse files
kimikagetimholy
authored andcommitted
Remove the obsolete promotions for reductions (#141)
1 parent 4341fe5 commit 4b9142b

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

src/FixedPointNumbers.jl

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ VERSION < v"0.7.0-beta2.199" && __precompile__()
22

33
module FixedPointNumbers
44

5-
using Base: reducedim_initarray
6-
75
import Base: ==, <, <=, -, +, *, /, ~, isapprox,
86
convert, promote_rule, show, isinteger, abs, decompose,
97
isnan, isinf, isfinite,
@@ -154,27 +152,12 @@ sizeof(::Type{T}) where {T <: FixedPoint} = sizeof(rawtype(T))
154152

155153
# Promotions for reductions
156154
const Treduce = Float64
157-
if isdefined(Base, :r_promote)
158-
# Julia v0.6
159-
Base.r_promote(::typeof(+), x::FixedPoint{T}) where {T} = Treduce(x)
160-
Base.r_promote(::typeof(*), x::FixedPoint{T}) where {T} = Treduce(x)
161-
Base.reducedim_init(f::typeof(identity),
162-
op::typeof(+),
163-
A::AbstractArray{T}, region) where {T <: FixedPoint} =
164-
Base.reducedim_initarray(A, region, zero(Treduce))
165-
Base.reducedim_init(f::typeof(identity),
166-
op::typeof(*),
167-
A::AbstractArray{T}, region) where {T <: FixedPoint} =
168-
Base.reducedim_initarray(A, region, oneunit(Treduce))
169-
else
170-
# Julia v0.7
171-
Base.add_sum(x::FixedPoint, y::FixedPoint) = Treduce(x) + Treduce(y)
172-
Base.reduce_empty(::typeof(Base.add_sum), ::Type{F}) where {F<:FixedPoint} = zero(Treduce)
173-
Base.reduce_first(::typeof(Base.add_sum), x::FixedPoint) = Treduce(x)
174-
Base.mul_prod(x::FixedPoint, y::FixedPoint) = Treduce(x) * Treduce(y)
175-
Base.reduce_empty(::typeof(Base.mul_prod), ::Type{F}) where {F<:FixedPoint} = one(Treduce)
176-
Base.reduce_first(::typeof(Base.mul_prod), x::FixedPoint) = Treduce(x)
177-
end
155+
Base.add_sum(x::FixedPoint, y::FixedPoint) = Treduce(x) + Treduce(y)
156+
Base.reduce_empty(::typeof(Base.add_sum), ::Type{F}) where {F<:FixedPoint} = zero(Treduce)
157+
Base.reduce_first(::typeof(Base.add_sum), x::FixedPoint) = Treduce(x)
158+
Base.mul_prod(x::FixedPoint, y::FixedPoint) = Treduce(x) * Treduce(y)
159+
Base.reduce_empty(::typeof(Base.mul_prod), ::Type{F}) where {F<:FixedPoint} = one(Treduce)
160+
Base.reduce_first(::typeof(Base.mul_prod), x::FixedPoint) = Treduce(x)
178161

179162

180163
for f in (:div, :fld, :fld1)

0 commit comments

Comments
 (0)