I do not understand the following element wise boolean operation result (see arrow on last part):
A = [1,2,3,1,2]
B = [1,2,1,3,2]
julia> A.==1
5-element BitArray{1}:
true
false
false
true
false
julia> B.==1
5-element BitArray{1}:
true
false
true
false
false
julia> A.==1 .& B.==1
5-element BitArray{1}:
true
false
false
true <----- I expect this to be false
false
The 4th element of A.==1 .& B.==1 should be false because it is (true & false). Can someone explain?
Operator precedence issue.
You have (by omission):
(A .== (1 .& B) .==1)
You need:
(A .== 1) .& (B .==1)
Relevant docs. Note that &
(defined as multiplication) comes before ==
(defined as comparison).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With