I would like to use something like np.dot
or (preferably) np.einsum
to efficiently perform their same function but with an alternate ufunc
instead of np.multiply
. For example, consider these two arrays:
>>> a
array([[0, 1],
[1, 1],
[1, 0]])
>>> b
array([[0, 0],
[1, 0],
[1, 0],
[0, 0]])
Now suppose I want to count the number of elements in each row of a
equal to the corresponding elements in each row of b
. I'd like to be able to do the equivalent of the following (note: the output below is fabricated but the values are what I would expect to see):
>>> np.dot(a, b.T, ufunc=np.equal)
array([[1, 0, 0, 1],
[0, 1, 1, 0],
[1, 2, 2, 1]])
Is there a way to do this?