How can I quickly extract two rows of a scipy.sparse.lil_matrix and apply bitwise operations on them? I've tried:
np.bitwise_and(A[1,:], A[2,:])
but NumPy seems to want an array type according to the documentation.
How can I quickly extract two rows of a scipy.sparse.lil_matrix and apply bitwise operations on them? I've tried:
np.bitwise_and(A[1,:], A[2,:])
but NumPy seems to want an array type according to the documentation.
By "lil_matrix", do you mean a scipy.sparse.lil_matrix? If so, you'll have to convert your sparse array to a normal dense array to do bitwise operations on it, I believe.
a = np.asarray(A.todense())
np.bitwise_and(a[1,:], a[2,:])
Should do the trick, I think...
EDIT: Forgot an "asarray" there...