Eliminating gaussian code modulo 2 python

I was wondering if Gaussian modulo 2 (or even modulo k altogether for this purpose) was eliminated, so I don’t need to reinvent the wheel and just use the available resources?

+5
source share
1 answer

The pseudo-code of the algorithm you are looking for exists and is:

// A is n by m binary matrix i := 1 // row and column index for i := 1 to m do // for every column // find non-zero element in column i, starting in row i: maxi := i for k := i to n do if A[k,i] = 1 then maxi := k end for if A[maxi,i] = 1 then swap rows i and maxi in A and b, but do not change the value of i Now A[i,i] will contain the old value of A[maxi,i], that is 1 for u := i+1 to m do Add A[u,i] * row i to row u, do this for BOTH, matrix A and RHS vector b Now A[u,i] will be 0 end for else declare error – more than one solution exist end if end for if n>m and if you can find zero row in A with nonzero RHS element, then declare error – no solution. end if // now, matrix A is in upper triangular form and solution can be found use back substitution to find vector x 

Taken from this pdf

Binary arithmetic means modulo 2 arithmetic, and this is what you are looking for in your question, if I'm not mistaken.

Unfortunately, I am not encoded in Python, but if you are familiar with Python, you can simply translate the pseudo-code above into Python one by one in your own way for your convenience, and this task should not be difficult either .

I googled "gaussian exception modulo 2 python", but did not find the python code you are looking for, but I think this is good, because during the translation you can better understand the algorithm and method.

EDIT 1: If you are also familiar with C #, and it’s easy for you to translate C # into Python, then Michael Anderson will answer this question , may also help you.

EDIT 2: after sending the response, I continued searching and found this

"by any field" means "modulo 2" and even "modulo k" for any k & ge; 2.

It contains the source code for the Java and Python versions.

According to the last link I gave you for the Python version of fieldmath.py , it includes the BinaryField class, which is supposed to be modulo 2 as you wish.

Enjoy it!

I just hope that the Gauss-Jordan exception and the Gaussian exception are not two different things.

EDIT 3: If you are also familiar with VC ++ and translating VC ++ into Python is not for you, you can also try this .

Hope this answers your question well.

+2
source

Source: https://habr.com/ru/post/1235245/


All Articles