Re: Subtraction between Boolean sparse matrices

"G. D. McBain" <[email protected]> Wed, 22 Sep 2021 23:59:06 +0000
Newsgroups gmane.comp.python.scientific.user
Message-ID <_wSx7Hdu7f7APudOoJRES1RA9xyavVK_cIN_XlRnTCWOlQGTcL-5tOeF9SM4qoo42LuI-WRbYo9rCq1D03PSEZHfmGBGVNI1pAUvq9qXI7E=@protonmail.com>
The XOR hypothesis is confirmed empirically by computing the truth table

https://en.wikipedia.org/wiki/Exclusive_or#Truth_table

A = coo_matrix([[True]*2 + [False]*2])
B = coo_matrix([[True, False]*2])
assert np.array_equal(
    np.logical_xor(A.toarray(), B.toarray()),
    (A - B).toarray()
)

Sent from ProtonMail, Swiss-based encrypted email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Le mercredi 22 septembre 2021 à 10:27 PM, <[email protected]> a écrit :

> What operation is performed when I subtract B from A, where both A and B are sparse matrices of Boolean elements?
>
> This operation is barred in numpy with regular arrays, but allowed in scipy.sparse. I believe it is XOR, but I could not follow the code to confirm this hypothesis.
>
> SciPy-User mailing list -- [email protected]
>
> To unsubscribe send an email to [email protected]
>
> https://mail.python.org/mailman3/lists/scipy-user.python.org/
>
> Member address: [email protected]
_______________________________________________
SciPy-User mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/scipy-user.python.org/
Member address: [email protected]