Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
A memory efficient form of Gaussian elimination to row echelon form modulo 2
ResourceFunction["BitStringRowReduce"][{n1,n2,…},ncols] treats the integers ni as vectors of zeros and ones, each having ncols bits, and does row reduction using mod 2 arithmetic. |
Reduce a list of integers bit-wise:
| In[1]:= |
| Out[1]= |
Create a random matrix of bit vectors:
| In[2]:= | ![]() |
| Out[6]= |
Now reduce it:
| In[7]:= |
| Out[7]= |
Create a large array of long integers:
| In[8]:= | ![]() |
BitStringRowReduce 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]= |
Use RowReduce modulo 2 to put it into echelon form:
| In[11]:= |
| Out[11]= |
Check that this agrees with the result from BitStringRowReduce:
| In[12]:= |
| Out[12]= |
Create a matrix of 0‐1 vectors corresponding to the larger integers:
| In[13]:= |
RowReduce is substantially slower as compared to BitStringRowReduce:
| In[14]:= |
| Out[14]= |
Again, check that the results are equivalent:
| In[15]:= |
| Out[15]= |
Here are the sizes in bytes of the input and result using the bit string approach:
| In[16]:= |
| Out[16]= |
Here are the corresponding sizes in bytes of the input and result when using an explicit matrix:
| In[17]:= |
| Out[17]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License