I would like to check if there is an easy way to implement a check of linear (in)dependence of vectors but using modular arithmetic mod 2.
For example, suppose you have the following 3 vectors:
- v1 = (1,1,0);
- v2 = (0,1,1);
- v3 = (1,0,1).
If we use scipy.linalg's null_space such that:
M = [[1,0,1],
[1,1,0],
[0,1,1]]
null_space(M)
we get as a result that the 3 vectors are linearly independent, which is obviously true.
However, what I want to check is linear (in)dependence considering modular arithmetic mod 2. In that case, it is easy to check that v3 = v1 + v2 (i.e., the three vectors are linearly dependent).
Is there any way to determine this in Python?
Thank you in advance.
UPDATE (02/01/2022): Is there an alternative to doing this with sympy as suggested in one of the answers below? While this solution works for small instances I have noticed (in growing the matrix size) that the code sometimes gets stuck for over 30hours without being able to move on. This is very dependent on the example, which I find fascinating. That is, for a given size while some examples are worked through reasonably quickly (~2hours) others get stuck and the code still hasn't found a solution after 30hours which is less than desirable.! So, is there really no way of doing this with numpy or something like that?