Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
A memory efficient form of computing the null space of a matrix modulo 2
ResourceFunction["BitStringNullSpace"][{n1,n2,…},ncols] treats the integers ni as vectors of zeros and ones, each having ncols bits, and returns integers representing a set of generators of the null space modulo 2. |
Find the modulo-2 null space of a simple matrix:
| In[1]:= |
| Out[1]= |
Create a random matrix of bit vectors:
| In[2]:= | ![]() |
| Out[6]= |
Find the 0‐1 null vectors mod 2, represented as integers:
| In[7]:= |
| Out[7]= |
Create a large array of bit strings to use as a matrix:
| In[8]:= | ![]() |
BitStringNullSpace is especially useful when working with matrices that might otherwise require excessive memory:
| In[9]:= |
| Out[9]= |
Here is the matrix from which the bit vectors were created:
| In[10]:= |
| Out[10]= |
We see that the prior result agrees with NullSpace:
| In[11]:= |
| Out[11]= |
| In[12]:= |
| Out[12]= |
| In[13]:= |
| Out[13]= |
Similarly, create a matrix of explicit 0‐1 vectors corresponding to the large integers:
| In[14]:= |
NullSpace is substantially slower as compared to BitStringNullSpace:
| In[15]:= |
| Out[15]= |
Check that the results agree:
| In[16]:= |
| Out[16]= |
This work is licensed under a Creative Commons Attribution 4.0 International License