diff --git a/base/bitarray.jl b/base/bitarray.jl index 34b62df427d7d..981c069cd50fb 100644 --- a/base/bitarray.jl +++ b/base/bitarray.jl @@ -1072,9 +1072,6 @@ function (.^){T<:Number}(B::BitArray, x::T) end end -(.*)(A::BitArray, B::BitArray) = A & B -(.*)(A::Array{Bool}, B::BitArray) = A & B -(.*)(B::BitArray, A::Array{Bool}) = A & B (.*)(x::Bool, B::BitArray) = x & B (.*)(B::BitArray, x::Bool) = B & x (.*)(x::Number, B::BitArray) = x .* bitunpack(B) diff --git a/base/broadcast.jl b/base/broadcast.jl index 925042351d0ac..27af246fe848c 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -381,4 +381,16 @@ function (.^){T<:Integer}(A::BitArray, B::Array{T}) return F end +for (sigA, sigB) in ((BitArray, BitArray), + (AbstractArray{Bool}, BitArray), + (BitArray, AbstractArray{Bool})) + @eval function (.*)(A::$sigA, B::$sigB) + try + return bitpack(A) & bitpack(B) + catch + return bitbroadcast(&, A, B) + end + end +end + end # module diff --git a/test/broadcast.jl b/test/broadcast.jl index 9a0157682ef1c..da188d43bf3ac 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -57,6 +57,7 @@ for arr in (identity, as_sub) @test arr([1 2]) ./ arr([3, 4]) == [1/3 2/3; 1/4 2/4] @test arr([1 2]) .\ arr([3, 4]) == [3 1.5; 4 2] @test arr([3 4]) .^ arr([1, 2]) == [3 4; 9 16] + @test arr(bitpack([true false])) .* arr(bitpack([true, true])) == [true false; true false] @test arr(bitpack([true false])) .^ arr(bitpack([false, true])) == [true true; true false] @test arr(bitpack([true false])) .^ arr([0, 3]) == [true true; true false]