-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add irreducible polynomials for GF(2^m) (2<=m<=10_000) #462
Add irreducible polynomials for GF(2^m) (2<=m<=10_000) #462
Conversation
I will not have time to do anything else today, so I expect many tests to fail, etc. but at least it gives an idea of what I meant in #461 and you can let me know if it makes sense to add this or not. |
Instead of always using the new |
Codecov ReportBase: 96.47% // Head: 96.35% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## release/0.3.x #462 +/- ##
=================================================
- Coverage 96.47% 96.35% -0.12%
=================================================
Files 47 44 -3
Lines 5758 5734 -24
=================================================
- Hits 5555 5525 -30
- Misses 203 209 +6
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Hey @iyanmv, thanks for submitting this PR. Generally, I like the idea and have had similar ones (see #140). Here are some thoughts below. While I like adding extra databases with cached polynomials (irreducible and primitive), I'm not a big fan of the The current way to get the lexicographically-first irreducible polynomial over In [30]: galois.irreducible_poly(2, 49)
Out[30]: Poly(x^49 + x^6 + x^5 + x^4 + 1, GF(2)) However, it has 5 terms and a polynomial with 3 terms exists Interestingly enough, I have a branch I was working on (not yet pushed) that adds a In [31]: galois.irreducible_poly(2, 49, terms=3)
Out[31]: Poly(x^49 + x^9 + 1, GF(2)) Bringing this full circle to your PR... Perhaps I can add a # Exists in database, so returns quickly
In [32]: galois.irreducible_poly(2, 10_000, terms="min")
Out[32]: Poly(x^10000 + x^19 + x^13 + x^9 + 1, GF(2))
# Does not exist in database, takes forever to find...
In [33]: galois.irreducible_poly(2, 10_001, terms="min") This paradigm could then be extended to irreducible polynomials of other orders and also primitive polynomials. What are your thoughts? |
I pushed my local branch up to #463 for you to take a look at what I mean. |
Oh, didn't see that issue before. I would have commented there directly.
Sounds good. I added
Really nice! I think that would be useful for different uses cases.
I like it! What would be the default value for |
How do you think I should continue with this PR? I can remove all changes regarding |
Also, I included the PDF because I had issues to get directly in the script using |
I was thinking of leaving it as
I will add a basic A couple other minor notes on the PR: Let's make the database more general. I was thinking I wouldn't recommend overriding the default irreducible polynomial in galois/src/galois/_databases/_conway.py Lines 38 to 45 in 5e45744
Yes, some tests broke because the test vectors generated from Sage also use Conway polynomials. So when an irreducible polynomial was used, the arithmetic didn't match.
I'll take a peek. There might be a way. |
Okay, I will work on those changes. |
afb1e90
to
c309aae
Compare
c309aae
to
25d0285
Compare
Black is indeed a truly uncompromising formatter 😂 |
25d0285
to
7f8b2ef
Compare
I think this should be ready as it is. I will finish the PR when #463 is merged. |
It is truly a pain in the ass! If you're using VS Code, I have a settings file that should auto-format your source files on save. Otherwise, you have to remember to run it -- see my first comment...
Great! I may still need a day or two to finish #463, though. |
b0988ed
to
1402a77
Compare
I think this database will coincide with the lexicographically-first computation done by galois. In any case, I will run your test here as well (although probably is not feasible to try all the way till import time
import galois
order = 2
degrees = range(2, 10_000)
different_polys = []
for degree in degrees:
print(f"{order}^{degree}:")
tick = time.time_ns()
p1 = galois.irreducible_poly(order, degree, terms="min", use_database=False)
tock = time.time_ns()
print(f"\tWithout database: {(tock - tick)*1e-9} seconds")
tick = time.time()
p2 = galois.irreducible_poly(order, degree, terms="min", use_database=True)
tock = time.time()
print(f"\tWith database: {(tock - tick)*1e-9} seconds")
print(f"\t{p1 == p2}\t{p1}\t{p2}")
assert p1 == p2 |
How far has the script made it? |
|
6cb821d
to
86a051e
Compare
|
I'm convinced the HP table contains the lexicographically-first irreducible polynomial. |
- New script to create a irreducible polynomials database - Add irreducible polynomials for GF(2^m) for m <= 10_000 using Gadiel Seroussi's table - New IrreduciblePolyDatabase class to handle access to the database
Similar to the changes in primitive_poly(), try to fetch nonzero degrees and coefficients from the database when irreducible_poly() is called with terms="min". If poly is not in the database, fallback to compute it.
- Add LUTs for a sample of irreducible polynomials from Gadiel Seroussi's table - Add test_minimum_terms_from_database
86a051e
to
5db9da8
Compare
I rebased this with #470 merged. Do you think this is ready to merge or to you want to do further changes? |
PR regarding #461 #140
GF(2^m)
for2<=m<=10_000
using Gadiel Seroussi's tableIrreduciblePolyDatabase
classgalois.irreducible_poly(2, m, terms="min")
(see Addterms
kwarg to irreducible and primitive poly functions #463)