Skip to content

Commit

Permalink
get rid of obsolete rcum_promote_type
Browse files Browse the repository at this point in the history
  • Loading branch information
jw3126 committed Jan 17, 2018
1 parent d8ac226 commit 9699be5
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -731,15 +731,6 @@ julia> findn(A)
end


# see discussion in #18364 ... we try not to widen type of the resulting array
# from cumsum or cumprod, but in some cases (+, Bool) we may not have a choice.
rcum_promote_type(op, ::Type{T}, ::Type{S}) where {T,S} = promote_op(op, T, S)
rcum_promote_type(op, ::Type{T}) where {T} = rcum_promote_type(op, T,T)

# handle sums of Vector{Bool} and similar. it would be nice to handle
# any AbstractArray here, but it's not clear how that would be possible
rcum_promote_type(op, ::Type{Array{T,N}}) where {T,N} = Array{rcum_promote_type(op,T), N}

# accumulate_pairwise slightly slower then accumulate, but more numerically
# stable in certain situations (e.g. sums).
# it does double the number of operations compared to accumulate,
Expand Down Expand Up @@ -773,7 +764,7 @@ function accumulate_pairwise!(op::Op, result::AbstractVector, v::AbstractVector)
end

function accumulate_pairwise(op, v::AbstractVector{T}) where T
out = similar(v, rcum_promote_type(op, T))
out = similar(v, promote_op(op, T))
return accumulate_pairwise!(op, out, v)
end

Expand Down Expand Up @@ -818,7 +809,7 @@ julia> cumsum(a,2)
```
"""
function cumsum(A::AbstractArray{T}, dim::Integer) where T
out = similar(A, rcum_promote_type(+, T))
out = similar(A, promote_op(+, T))
cumsum!(out, A, dim)
end

Expand Down Expand Up @@ -952,7 +943,7 @@ julia> accumulate(+, fill(1, 3, 3), 2)
```
"""
function accumulate(op, A, dim::Integer)
out = similar(A, rcum_promote_type(op, eltype(A)))
out = similar(A, promote_op(op, eltype(A)))
accumulate!(op, out, A, dim)
end

Expand Down Expand Up @@ -1101,7 +1092,7 @@ julia> accumulate(min, 0, [1,2,-1])
```
"""
function accumulate(op, v0, x::AbstractVector)
T = rcum_promote_type(op, typeof(v0), eltype(x))
T = promote_op(op, typeof(v0), eltype(x))
out = similar(x, T)
accumulate!(op, out, v0, x)
end
Expand Down

0 comments on commit 9699be5

Please sign in to comment.