Skip to content

Commit

Permalink
Keep binary operations on pairs of arrays fast
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloferz committed Jul 13, 2016
1 parent 3803ee4 commit 01fc529
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion base/arraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ end

for f in (:+, :-, :div, :mod, :&, :|, :$)
@eval ($f){S,T}(A::AbstractArray{S}, B::AbstractArray{T}) =
_elementwise($f, A, B, promote_eltype_op($f, A, B))
_elementwise($f, A, B, promote_op($f, S, T))
end
function _elementwise{S,T}(op, A::AbstractArray{S}, B::AbstractArray{T}, ::Type{Any})
promote_shape(A,B) # check size compatibility
Expand Down
6 changes: 3 additions & 3 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Broadcast

using Base.Cartesian
using Base: promote_op, promote_eltype, promote_eltype_op, @get!, _msk_end, unsafe_bitgetindex, linearindices, to_shape, tail, dimlength, OneTo
using Base: promote_op, promote_eltype_op, @get!, _msk_end, unsafe_bitgetindex, linearindices, to_shape, tail, dimlength, OneTo
import Base: .+, .-, .*, ./, .\, .//, .==, .<, .!=, .<=, , .%, .<<, .>>, .^
export broadcast, broadcast!, bitbroadcast
export broadcast_getindex, broadcast_setindex!
Expand Down Expand Up @@ -277,8 +277,8 @@ eltype_plus(As::AbstractArray...) = promote_eltype_op(+, As...)
for op in (:+, :*, :÷, :%, :<<, :>>, :-, :/, :\, ://, :^)
@eval begin
function $(Symbol(:., op))(A::AbstractArray, B::AbstractArray)
T = Base.promote_op($(op), eltype(A), eltype(B))
return broadcast_t($(op), T, A, B)
T = promote_op($op, eltype(A), eltype(B))
return broadcast_t($op, T, A, B)
end
end
end
Expand Down

0 comments on commit 01fc529

Please sign in to comment.