I've got two boolean vectors a = [1,1,1]
and b = [0,1,1]
where obviously 1
stands for true
and 0
for false
.
I want to calculate their inner product using Boolean algebra. The result I want is therefore
1*0 + 1*1 + 1*1 = 0 + 1 + 1 = 0
because addition plays the role of exclusive or (XOR).
I know that the product part can be done like this
a = [true, true, true] # could also use ones(Bool, 3)
b = [false, true, true]
bitwise_prod = a .& b
but I don't know how to do the sum. Any ideas?
⊻
, which you get by typing\xor
, should work, too. – Wolfe