-
Notifications
You must be signed in to change notification settings - Fork 275
Buchberger naive for fmpz_mod_mpoly #2445
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
base: main
Are you sure you want to change the base?
Conversation
src/fmpz_mod_mpoly.h
Outdated
| void _fmpz_mod_mpoly_vec_fmpz_mod_mpoly_to_fmpz_mpoly(fmpz_mpoly_vec_t ret, fmpz_mod_mpoly_vec_t src, fmpz_mod_mpoly_ctx_t ctx); | ||
| void _fmpz_mod_mpoly_vec_fmpz_mpoly_to_fmpz_mod_mpoly(fmpz_mod_mpoly_vec_t ret, fmpz_mpoly_vec_t src, fmpz_mod_mpoly_ctx_t ctx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are these defined? I can't seem to find it.
src/fmpz_mod_mpoly/buchberger.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this file if it is unused
src/fmpz_mod_mpoly.h
Outdated
| #endif | ||
|
|
||
| #include "fmpz.h" | ||
| #include "fmpz_mpoly.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this inclusion is necessary.
| if (fmpz_mod_mpoly_length(poly, ctx) > poly_len_limit) | ||
| return 0; | ||
|
|
||
| bits = _fmpz_vec_max_bits(poly->coeffs, poly->length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer needed.
doc/source/fmpz_mod_mpoly.rst
Outdated
| ------------------------------------------------------------------------------- | ||
|
|
||
| The following methods deal with ideals in `\mathbb{Z}/n\mathbb{Z}[x_1, \dots, x_m]`. | ||
| We use primitive integer polynomials as normalised generators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The normalised generators will be monic, not primitive integer polynomials.
src/fmpz_mod_mpoly/spoly.c
Outdated
| for (i = 0; i < n; i++) | ||
| exp[i] = FLINT_MAX(expf[i], expg[i]); | ||
|
|
||
| fmpz_mod_inv(c, f->coeffs, ctx->ffinfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check if the leading coefficients are 1, and then you don't need to invert them and multiply by them below.
| #include "fmpz_mod_mpoly.h" | ||
|
|
||
| void | ||
| fmpz_mod_mpoly_vec_set_monic_unique(fmpz_mod_mpoly_vec_t G, const fmpz_mod_mpoly_vec_t F, const fmpz_mod_mpoly_ctx_t ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File should be renamed to match the function name.
| fmpz_mod_mpoly_vec_init(H, 0, ctx); | ||
|
|
||
|
|
||
| // flint_printf("iter %ld %ld %d %d \n\n", iter, nvars, ctx->minfo->ord, m); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a comment, but you can change the format string to iter %wd %wd %d %{fmpz}
|
There is maybe some bug in the algorithm. I tried to get some bigger examples by setting On iteration 224 we get Sage tells me But the vector I guess one can find a much smaller bad case; I just took the first really big one I saw that looked suspect. |
|
More manageable example: 3 variables, mod 17 Sage says that H is not a Groebner basis. |
|
Oh wait, I'm stupid. I forgot about term orders! SageMath doesn't use lex ordering by default. The |
|
Fun fact: I tried and it's still going after 20 minutes. FLINT did this one in 14 seconds. Is this Singular being slow, Sage doing something bad, or FLINT being fast? Edit: Sage (Singular?) was killed by the OS after about 30 minutes. |
| { | ||
| fmpz_t c; | ||
| fmpz_mod_inv(c, f->coeffs, ctx->ffinfo); | ||
| fmpz_init(c); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fmpz_init needs to be moved one line up. Same in the block below.
One way that seems to work more efficiently in Sage is to use the R.<x1,x2,x3> = PolynomialRing(GF(4722366482869611659327), order='lex')
F = [4491077222722822274764*x1^3*x2^2*x3^3+1142989093829542840957*x1*x2*x3+161135877041952360283*x2^2*x3^2+1963195568815792903903*x3^2, 473518656873042772582*x1^3*x2^2*x3^2+538964973504606229287*x1^3*x3^3+ 2996428526938692536564*x1^2*x2^2*x3^2+1389613235437080610847*x1*x3]
S = R.change_ring(order='degrevlex')
G = (S*F).transformed_basis()Edit: this basis does not seem reduced though. Reducing it took around 9 seconds on my laptop, and can be done as follows. Gred = (R*G).groebner_basis() |
|
Output from FLINT: GB.txt |
|
Magma converts between orders "automatically", I do not know the details. |
|
Naming:
|
|
Can you undo the changes to |
Added a fmpz_mod_mpoly version of Buchberger algorithm used in fmpz_mod_mpoly.