The broadcast function assumes that the output array is the same type as
the input arrays. You can do something like this with the mutating
broadcast! function:

julia> broadcast!(==, falses(2,2), [1,2], [2,1]')
2x2 BitArray{2}:
 false   true
  true  false


Also, you can just use the .== function, which automatically does the
correct broadcasting for you:

julia> [1.0] .== [0.0,1.0]
2-element BitArray{1}:
 false
  true


On Thu, Apr 30, 2015 at 2:50 PM, Alexandros Fakos <[email protected]
> wrote:

> Hi,
>
> Why the following commands give different results?
>
> julia> broadcast(.==,[1.0],[0.0,1.0])
> 2-element Array{Float64,1}:
>  0.0
>  1.0
>
> julia> repmat([1.0],2,1).==[0.0,1.0]
> 2x1 BitArray{2}:
>  false
>   true
>
>
>
> How can I use broadcast for array comparisons (with a bit array as output)?
>
> Thanks,
> Alex
>

Reply via email to