Skip to content

Commit c7300b0

Browse files
authored
Merge pull request #17 from ederc/f4-finite-field-fix
F4 finite field fix
2 parents 174ba9f + da30f6d commit c7300b0

File tree

8 files changed

+35
-30
lines changed

8 files changed

+35
-30
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "AlgebraicSolving"
22
uuid = "66b61cbe-0446-4d5d-9090-1ff510639f9d"
33
authors = ["ederc <[email protected]>",
44
"Mohab Safey El Din <[email protected]"]
5-
version = "0.3.3"
5+
version = "0.3.4"
66

77
[deps]
88
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -14,4 +14,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1414
[compat]
1515
julia = "1.6"
1616
msolve_jll = "0.4.6"
17-
Nemo = "0.32.5, 0.33, 0.34, 0.35"
17+
Nemo = "0.35.1"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Nemo = "2edaba10-b0f1-5616-af89-8c11ac63239a"
99
[compat]
1010
Documenter = "0.26"
1111
msolve_jll = "0.4.1"
12-
Nemo = "0.32.0"
12+
Nemo = "0.35.1"

src/algorithms/groebner-bases.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ At the moment the underlying algorithm is based on variants of Faugère's F4 Alg
2727
julia> using AlgebraicSolving
2828
2929
julia> R, (x,y,z) = PolynomialRing(GF(101),["x","y","z"], ordering=:degrevlex)
30-
(Multivariate Polynomial Ring in x, y, z over Galois field with characteristic 101, Nemo.gfp_mpoly[x, y, z])
30+
(Multivariate polynomial ring in 3 variables over GF(101), Nemo.fpMPolyRingElem[x, y, z])
3131
3232
julia> I = Ideal([x+2*y+2*z-1, x^2+2*y^2+2*z^2-x, 2*x*y+2*y*z-y])
33-
Nemo.gfp_mpoly[x + 2*y + 2*z + 100, x^2 + 2*y^2 + 2*z^2 + 100*x, 2*x*y + 2*y*z + 100*y]
33+
Nemo.fpMPolyRingElem[x + 2*y + 2*z + 100, x^2 + 2*y^2 + 2*z^2 + 100*x, 2*x*y + 2*y*z + 100*y]
3434
3535
julia> eliminate(I, 2)
36-
1-element Vector{Nemo.gfp_mpoly}:
36+
1-element Vector{Nemo.fpMPolyRingElem}:
3737
z^4 + 38*z^3 + 95*z^2 + 95*z
3838
```
3939
"""
@@ -81,20 +81,20 @@ At the moment the underlying algorithm is based on variants of Faugère's F4 Alg
8181
julia> using AlgebraicSolving
8282
8383
julia> R, (x,y,z) = PolynomialRing(GF(101),["x","y","z"], ordering=:degrevlex)
84-
(Multivariate Polynomial Ring in x, y, z over Galois field with characteristic 101, Nemo.gfp_mpoly[x, y, z])
84+
(Multivariate polynomial ring in 3 variables over GF(101), Nemo.fpMPolyRingElem[x, y, z])
8585
8686
julia> I = Ideal([x+2*y+2*z-1, x^2+2*y^2+2*z^2-x, 2*x*y+2*y*z-y])
87-
Nemo.gfp_mpoly[x + 2*y + 2*z + 100, x^2 + 2*y^2 + 2*z^2 + 100*x, 2*x*y + 2*y*z + 100*y]
87+
Nemo.fpMPolyRingElem[x + 2*y + 2*z + 100, x^2 + 2*y^2 + 2*z^2 + 100*x, 2*x*y + 2*y*z + 100*y]
8888
8989
julia> groebner_basis(I)
90-
4-element Vector{Nemo.gfp_mpoly}:
90+
4-element Vector{Nemo.fpMPolyRingElem}:
9191
x + 2*y + 2*z + 100
9292
y*z + 82*z^2 + 10*y + 40*z
9393
y^2 + 60*z^2 + 20*y + 81*z
9494
z^3 + 28*z^2 + 64*y + 13*z
9595
9696
julia> groebner_basis(I, eliminate=2)
97-
1-element Vector{Nemo.gfp_mpoly}:
97+
1-element Vector{Nemo.fpMPolyRingElem}:
9898
z^4 + 38*z^3 + 95*z^2 + 95*z
9999
```
100100
"""

src/algorithms/solvers.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@ is greater then zero an empty array is returned.
216216
julia> using AlgebraicSolving
217217
218218
julia> R,(x1,x2,x3) = PolynomialRing(QQ, ["x1","x2","x3"])
219-
(Multivariate Polynomial Ring in x1, x2, x3 over Rational Field, Nemo.fmpq_mpoly[x1, x2, x3])
219+
(Multivariate polynomial ring in 3 variables over QQ, Nemo.QQMPolyRingElem[x1, x2, x3])
220220
221221
julia> I = Ideal([x1+2*x2+2*x3-1, x1^2+2*x2^2+2*x3^2-x1, 2*x1*x2+2*x2*x3-x2])
222-
Nemo.fmpq_mpoly[x1 + 2*x2 + 2*x3 - 1, x1^2 - x1 + 2*x2^2 + 2*x3^2, 2*x1*x2 + 2*x2*x3 - x2]
222+
Nemo.QQMPolyRingElem[x1 + 2*x2 + 2*x3 - 1, x1^2 - x1 + 2*x2^2 + 2*x3^2, 2*x1*x2 + 2*x2*x3 - x2]
223223
224224
julia> rational_parametrization(I)
225-
AlgebraicSolving.RationalParametrization([:x1, :x2, :x3], fmpz[], 84*x^4 - 40*x^3 + x^2 + x, 336*x^3 - 120*x^2 + 2*x + 1, AbstractAlgebra.PolyElem[184*x^3 - 80*x^2 + 4*x + 1, 36*x^3 - 18*x^2 + 2*x])
225+
AlgebraicSolving.RationalParametrization([:x1, :x2, :x3], Nemo.ZZRingElem[], 84*x^4 - 40*x^3 + x^2 + x, 336*x^3 - 120*x^2 + 2*x + 1, AbstractAlgebra.PolyRingElem[184*x^3 - 80*x^2 + 4*x + 1, 36*x^3 - 18*x^2 + 2*x])
226226
```
227227
"""
228228
function rational_parametrization(
@@ -269,18 +269,18 @@ the rational roots of the ideal.
269269
julia> using AlgebraicSolving
270270
271271
julia> R,(x1,x2,x3) = PolynomialRing(QQ, ["x1","x2","x3"])
272-
(Multivariate Polynomial Ring in x1, x2, x3 over Rational Field, Nemo.fmpq_mpoly[x1, x2, x3])
272+
(Multivariate polynomial ring in 3 variables over QQ, Nemo.QQMPolyRingElem[x1, x2, x3])
273273
274274
julia> I = Ideal([x1+2*x2+2*x3-1, x1^2+2*x2^2+2*x3^2-x1, 2*x1*x2+2*x2*x3-x2])
275-
Nemo.fmpq_mpoly[x1 + 2*x2 + 2*x3 - 1, x1^2 - x1 + 2*x2^2 + 2*x3^2, 2*x1*x2 + 2*x2*x3 - x2]
275+
Nemo.QQMPolyRingElem[x1 + 2*x2 + 2*x3 - 1, x1^2 - x1 + 2*x2^2 + 2*x3^2, 2*x1*x2 + 2*x2*x3 - x2]
276276
277277
julia> rat_sols = rational_solutions(I)
278-
2-element Vector{Vector{fmpq}}:
278+
2-element Vector{Vector{Nemo.QQFieldElem}}:
279279
[1, 0, 0]
280280
[1//3, 0, 1//3]
281281
282282
julia> map(r->map(p->evaluate(p, r), I.gens), rat_sols)
283-
2-element Vector{Vector{fmpq}}:
283+
2-element Vector{Vector{Nemo.QQFieldElem}}:
284284
[0, 0, 0]
285285
[0, 0, 0]
286286
```
@@ -365,13 +365,13 @@ is greater than zero an empty array is returned.
365365
julia> using AlgebraicSolving
366366
367367
julia> R,(x1,x2,x3) = PolynomialRing(QQ, ["x1","x2","x3"])
368-
(Multivariate Polynomial Ring in x1, x2, x3 over Rational Field, Nemo.fmpq_mpoly[x1, x2, x3])
368+
(Multivariate polynomial ring in 3 variables over QQ, Nemo.QQMPolyRingElem[x1, x2, x3])
369369
370370
julia> I = Ideal([x1+2*x2+2*x3-1, x1^2+2*x2^2+2*x3^2-x1, 2*x1*x2+2*x2*x3-x2])
371-
Nemo.fmpq_mpoly[x1 + 2*x2 + 2*x3 - 1, x1^2 - x1 + 2*x2^2 + 2*x3^2, 2*x1*x2 + 2*x2*x3 - x2]
371+
Nemo.QQMPolyRingElem[x1 + 2*x2 + 2*x3 - 1, x1^2 - x1 + 2*x2^2 + 2*x3^2, 2*x1*x2 + 2*x2*x3 - x2]
372372
373373
julia> real_solutions(I)
374-
4-element Vector{Vector{fmpq}}:
374+
4-element Vector{Vector{Nemo.QQFieldElem}}:
375375
[5416829397//8589934592, 2708414699//8589934592, -2844258330290649520990905062759917788583//21778071482940061661655974875633165533184]
376376
[1, 0, 0]
377377
[1945971683//8589934592, 972985841//8589934592, 744426424910260862653434112767010536665//2722258935367507707706996859454145691648]

src/examples/katsura.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Also note that indices have been shifted to start from 1.
2525
julia> using AlgebraicSolving
2626
2727
julia> katsura(2)
28-
Nemo.fmpq_mpoly[x1 + 2*x2 + 2*x3 - 1, x1^2 + 2*x2^2 + 2*x3^2 - x1, 2*x1*x2 + 2*x2*x3 - x2]
28+
Nemo.QQMPolyRingElem[x1 + 2*x2 + 2*x3 - 1, x1^2 + 2*x2^2 + 2*x3^2 - x1, 2*x1*x2 + 2*x2*x3 - x2]
2929
```
3030
"""
3131
function katsura(log_solutions::Int, characteristic::Int=0)
@@ -50,10 +50,10 @@ Returns the Katsura ideal in the given polynomial ring `R`.
5050
julia> using AlgebraicSolving
5151
5252
julia> R, _ = QQ["x", "y", "z"]
53-
(Multivariate Polynomial Ring in x, y, z over Rational Field, Nemo.fmpq_mpoly[x, y, z])
53+
(Multivariate polynomial ring in 3 variables over QQ, Nemo.QQMPolyRingElem[x, y, z])
5454
5555
julia> katsura(R)
56-
Nemo.fmpq_mpoly[x + 2*y + 2*z - 1, x^2 - x + 2*y^2 + 2*z^2, 2*x*y + 2*y*z - y]
56+
Nemo.QQMPolyRingElem[x + 2*y + 2*z - 1, x^2 - x + 2*y^2 + 2*z^2, 2*x*y + 2*y*z - y]
5757
```
5858
"""
5959
function katsura(R::MPolyRing)

src/exports.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export PolynomialRing, MPolyRing, GFElem, MPoly, MPolyElem, FiniteField, GF,
2-
characteristic, ZZ, QQ, vars, nvars, ngens, fmpz, fmpq, fmpq_poly,
3-
base_ring, coefficient_ring, evaluate
2+
characteristic, degree, ZZ, QQ, vars, nvars, ngens, fmpz, fmpq, fmpq_poly,
3+
base_ring, coefficient_ring, evaluate, prime_field

src/imports.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ using LinearAlgebra
77
import Nemo:
88
bell,
99
binomial,
10+
degree,
1011
denominator,
1112
divexact,
1213
divides,
@@ -42,10 +43,14 @@ import Nemo:
4243
PolyElem,
4344
PolynomialRing,
4445
PolyRing,
46+
prime_field,
4547
primorial,
4648
QQ,
49+
QQFieldElem,
50+
QQMPolyRingElem,
4751
rising_factorial,
4852
root,
4953
unit,
5054
vars,
51-
ZZ
55+
ZZ,
56+
ZZRingElem

src/interfaces/nemo.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ function _convert_to_msolve(
1818
nr_terms = sum(lens)
1919
field_char = characteristic(R)
2020

21-
if field_char > 2^31
22-
error("At the moment we only support finite fields up to prime characteristic < 2^31.")
21+
if field_char > 2^31 || degree(base_ring(R)) != 1
22+
error("At the moment we only support prime fields up to prime characteristic < 2^31.")
2323
end
2424
# get coefficients
2525
if field_char == 0
@@ -37,7 +37,7 @@ function _convert_to_msolve(
3737
else
3838
for i in 1:nr_gens
3939
for cf in coefficients(F[i])
40-
push!(cfs, Int32(data(cf)))
40+
push!(cfs, Int32(data(prime_field(base_ring(R))(cf))))
4141
end
4242
end
4343
end
@@ -85,7 +85,7 @@ function _convert_finite_field_gb_to_abstract_algebra(
8585
nr_vars = nvars(R)
8686
CR = coefficient_ring(R)
8787

88-
basis = Nemo.gfp_mpoly[]
88+
basis = []
8989
#= basis = Vector{MPolyElem}(undef, bld) =#
9090

9191
len = 0

0 commit comments

Comments
 (0)