-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Alternative for removed poly_to_generator_matrix #543
Comments
Ah, sorry for the breaking change for you. My intent was for that functionality The function you want to use still exists, it's just removed from the API. You can access it with galois/src/galois/_codes/_cyclic.py Lines 193 to 222 in 25baec4
|
Ah, gotcha--that's very helpful! Now, if I may, I have a super trivial question about generating the parity check and generator matrices. For example, I want to generate these for the Hamming [7,4] code. I presume I would do something like the following: from galois._codes._cyclic import _poly_to_parity_check_matrix, _poly_to_generator_matrix
g = galois.primitive_poly(2, 3)
G = galois._codes._cyclic._poly_to_generator_matrix(7, g, systematic=False)
H = galois._codes._cyclic._poly_to_parity_check_matrix(7, g, systematic=False)
print(H)
>>> [[1 1 0 1 0 0 0]
>>> [0 1 1 0 1 0 0]
>>> [0 0 1 1 0 1 0]
>>> [0 0 0 1 1 0 1]] It seems odd to me that I'm not an expert in Galois fields or coding theory, so I'm likely asking something quite trivial and am outside of my element. Any input you could provide on the above in terms of being able to generate any matrices G and H for a general Hamming code would be much appreciated! *(as an aside question, I take it the column order does not matter, right?) Thank you again for the help, @mhostetter |
Ah. So for The generator and parity-check polynomial are related like this galois/src/galois/_codes/_cyclic.py Lines 24 to 53 in 25baec4
Yes, the order of the columns in G and rows in H can be arbitrarily swapped. |
Thank you for the response, and I apologize for taking so long to respond. Great, so extracting the relevant bits of code from the import galois
from galois import Poly
from galois._codes._cyclic import _poly_to_parity_check_matrix, _poly_to_generator_matrix
n, k, d = 7, 4, 3
generator_poly = galois.primitive_poly(2, d)
f = Poly.Degrees([n, 0], [1, -1], field=generator_poly.field)
parity_check_poly, remainder_poly = divmod(f, generator_poly)
G = _poly_to_generator_matrix(n, generator_poly, systematic=True)
H = _poly_to_parity_check_matrix(n, parity_check_poly, systematic=True) yields a matrix
which appears to (modulo the column order) be equal to the "H" matrix for the (n=7,k=4,d=3) parity check matrix from the Wikipedia link Taking this one step further to the Hamming [8,4] parity check matrix, running the above code with the altered values of n, k, d = 8, 4, 3 yield this matrix
which it seems is equivalent (up to row and column operations) to the matrix here in the section describing the Hamming [8,4] matrix given as Probably all trivial questions, but the fact that the matrices are equivalent (modulo row and column operations) is expected and okay presumably, right? My apologies if these are all super trivial. You can feel free to close this issue out as I think you answered my original question. Thank you again for all the help! |
I believe so, but I haven't implemented Hamming codes before. |
Reading the most up-to-date docs, I see that the changelog includes that
poly_to_generator_matrix
is no longer supported.While the other elements in the changelog had some points about what to update in lieu of the change, this series of changes did not appear to have any such alternatives. Is there another way to achieve the same functionality with the up-to-date
galois
package that can be recommended?Thank you again!
The text was updated successfully, but these errors were encountered: