I am trying to determine how to perform binary matrix multiplication in Python / Numpy / Scipy where instead of plus (addition), OR is used, meaning when we "multiply" the two matrices below
1 0
1 1
0 1
1 1 0
0 1 1
we should get
[[1., 1., 0],
[1., 1., 1.],
[0, 1., 1.]]
Any ideas?
> a = np.matrix([[1,1,0],[0,1,1]], dtype=bool)
> a.T * a
matrix([[ True, True, False],
[ True, True, True],
[False, True, True]], dtype=bool)
Normal numpy arrays have access to matrix-style multiplication via the dot
function.
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