Skip to content

Commit

Permalink
chore: adjust compat entry for Nemo and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma committed Jan 4, 2024
1 parent 40127ab commit 55f6b4e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 33 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AlgebraicSolving"
uuid = "66b61cbe-0446-4d5d-9090-1ff510639f9d"
authors = ["ederc <[email protected]>", "Mohab Safey El Din <[email protected]", "Rafael Mohr <[email protected]>"]
version = "0.4.5"
version = "0.4.6"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -17,7 +17,7 @@ msolve_jll = "6d01cc9a-e8f6-580e-8c54-544227e08205"

[compat]
LoopVectorization = "0.12"
Nemo = "0.35.1, 0.36, 0.37, 0.38"
Nemo = "0.35.1, 0.36, 0.37, 0.38, 0.39"
StaticArrays = "1"
julia = "1.6"
LinearAlgebra = "1.6"
Expand Down
1 change: 0 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ Nemo = "2edaba10-b0f1-5616-af89-8c11ac63239a"
[compat]
Documenter = "0.26"
msolve_jll = "0.6.1"
Nemo = "0.35.1"
14 changes: 7 additions & 7 deletions src/algorithms/groebner-bases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ At the moment the underlying algorithm is based on variants of Faugère's F4 Alg
julia> using AlgebraicSolving
julia> R, (x,y,z) = polynomial_ring(GF(101),["x","y","z"], ordering=:degrevlex)
(Multivariate polynomial ring in 3 variables over GF(101), fpMPolyRingElem[x, y, z])
(Multivariate polynomial ring in 3 variables over GF(101), Nemo.FqMPolyRingElem[x, y, z])
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])
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]
Nemo.FqMPolyRingElem[x + 2*y + 2*z + 100, x^2 + 2*y^2 + 2*z^2 + 100*x, 2*x*y + 2*y*z + 100*y]
julia> eliminate(I, 2)
1-element Vector{fpMPolyRingElem}:
1-element Vector{Nemo.FqMPolyRingElem}:
z^4 + 38*z^3 + 95*z^2 + 95*z
```
"""
Expand Down Expand Up @@ -81,20 +81,20 @@ At the moment the underlying algorithm is based on variants of Faugère's F4 Alg
julia> using AlgebraicSolving
julia> R, (x,y,z) = polynomial_ring(GF(101),["x","y","z"], ordering=:degrevlex)
(Multivariate polynomial ring in 3 variables over GF(101), fpMPolyRingElem[x, y, z])
(Multivariate polynomial ring in 3 variables over GF(101), Nemo.FqMPolyRingElem[x, y, z])
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])
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]
Nemo.FqMPolyRingElem[x + 2*y + 2*z + 100, x^2 + 2*y^2 + 2*z^2 + 100*x, 2*x*y + 2*y*z + 100*y]
julia> groebner_basis(I)
4-element Vector{fpMPolyRingElem}:
4-element Vector{Nemo.FqMPolyRingElem}:
x + 2*y + 2*z + 100
y*z + 82*z^2 + 10*y + 40*z
y^2 + 60*z^2 + 20*y + 81*z
z^3 + 28*z^2 + 64*y + 13*z
julia> groebner_basis(I, eliminate=2)
1-element Vector{fpMPolyRingElem}:
1-element Vector{Nemo.FqMPolyRingElem}:
z^4 + 38*z^3 + 95*z^2 + 95*z
```
"""
Expand Down
12 changes: 6 additions & 6 deletions src/algorithms/normal-forms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Gröbner basis, then this one is first computed.
julia> using AlgebraicSolving
julia> R, (x,y) = polynomial_ring(GF(101),["x","y"])
(Multivariate polynomial ring in 2 variables over GF(101), fpMPolyRingElem[x, y])
(Multivariate polynomial ring in 2 variables over GF(101), Nemo.FqMPolyRingElem[x, y])
julia> I = Ideal([y*x^3+12-y, x+y])
fpMPolyRingElem[x^3*y + 100*y + 12, x + y]
Nemo.FqMPolyRingElem[x^3*y + 100*y + 12, x + y]
julia> f = 2*x^2+7*x*y
2*x^2 + 7*x*y
Expand Down Expand Up @@ -74,18 +74,18 @@ Gröbner basis, then this one is first computed.
julia> using AlgebraicSolving
julia> R, (x,y) = polynomial_ring(GF(101),["x","y"])
(Multivariate polynomial ring in 2 variables over GF(101), fpMPolyRingElem[x, y])
(Multivariate polynomial ring in 2 variables over GF(101), Nemo.FqMPolyRingElem[x, y])
julia> I = Ideal([y*x^3+12-y, x+y])
fpMPolyRingElem[x^3*y + 100*y + 12, x + y]
Nemo.FqMPolyRingElem[x^3*y + 100*y + 12, x + y]
julia> F = [2*x^2+7*x*y, x+y]
2-element Vector{fpMPolyRingElem}:
2-element Vector{Nemo.FqMPolyRingElem}:
2*x^2 + 7*x*y
x + y
julia> normal_form(F,I)
2-element Vector{fpMPolyRingElem}:
2-element Vector{Nemo.FqMPolyRingElem}:
96*y^2
0
```
Expand Down
18 changes: 9 additions & 9 deletions src/siggb/siggb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ signature and the second the underlying polynomial.
julia> using AlgebraicSolving
julia> R, vars = polynomial_ring(GF(17), ["x$i" for i in 1:4])
(Multivariate polynomial ring in 4 variables over GF(17), fpMPolyRingElem[x1, x2, x3, x4])
(Multivariate polynomial ring in 4 variables over GF(17), Nemo.FqMPolyRingElem[x1, x2, x3, x4])
julia> F = AlgebraicSolving.cyclic(R)
fpMPolyRingElem[x1 + x2 + x3 + x4, x1*x2 + x1*x4 + x2*x3 + x3*x4, x1*x2*x3 + x1*x2*x4 + x1*x3*x4 + x2*x3*x4, x1*x2*x3*x4 + 16]
Nemo.FqMPolyRingElem[x1 + x2 + x3 + x4, x1*x2 + x1*x4 + x2*x3 + x3*x4, x1*x2*x3 + x1*x2*x4 + x1*x3*x4 + x2*x3*x4, x1*x2*x3*x4 + 16]
julia> Fhom = AlgebraicSolving._homogenize(F.gens)
4-element Vector{fpMPolyRingElem}:
4-element Vector{Nemo.FqMPolyRingElem}:
x1 + x2 + x3 + x4
x1*x2 + x2*x3 + x1*x4 + x3*x4
x1*x2*x3 + x1*x2*x4 + x1*x3*x4 + x2*x3*x4
x1*x2*x3*x4 + 16*x5^4
julia> sig_groebner_basis(Fhom)
7-element Vector{Tuple{Tuple{Int64, fpMPolyRingElem}, fpMPolyRingElem}}:
7-element Vector{Tuple{Tuple{Int64, Nemo.FqMPolyRingElem}, Nemo.FqMPolyRingElem}}:
((1, 1), x1 + x2 + x3 + x4)
((2, 1), x2^2 + 2*x2*x4 + x4^2)
((3, 1), x2*x3^2 + x3^2*x4 + 16*x2*x4^2 + 16*x4^3)
Expand All @@ -59,7 +59,7 @@ julia> sig_groebner_basis(Fhom)
```
"""
function sig_groebner_basis(sys::Vector{T}; info_level::Int=0, degbound::Int=0) where {T <: MPolyRingElem}
R = first(sys).parent
R = parent(first(sys))
Rchar = characteristic(R)

# check if input is ok
Expand Down Expand Up @@ -131,9 +131,9 @@ function sig_groebner_basis(sys::Vector{T}; info_level::Int=0, degbound::Int=0)
m = monomial(SVector{nv}((Exp).(exps[j])))
eidx = insert_in_hash_table!(basis_ht, m)
if isone(j)
inver = inv(Coeff(cfs[1].data), char)
inver = inv(Coeff(lift(ZZ, cfs[1])), char)
end
cf = isone(j) ? one(Coeff) : mul(inver, Coeff(cfs[j].data), char)
cf = isone(j) ? one(Coeff) : mul(inver, Coeff(lift(ZZ, cfs[j])), char)
mons[j] = eidx
coeffs[j] = cf
end
Expand Down Expand Up @@ -181,13 +181,13 @@ function sig_groebner_basis(sys::Vector{T}; info_level::Int=0, degbound::Int=0)
exps = [basis_ht.exponents[m].exps for m in basis.monomials[i]]
ctx = MPolyBuildCtx(R)
for (e, c) in zip(exps, basis.coefficients[i])
push_term!(ctx, c, Vector{Int}(e))
push_term!(ctx, coefficient_ring(R)(c), Vector{Int}(e))
end
pol = finish(ctx)

s = basis.sigs[i]
ctx = MPolyBuildCtx(R)
push_term!(ctx, 1, Vector{Int}(monomial(s).exps))
push_term!(ctx, one(coefficient_ring(R)), Vector{Int}(monomial(s).exps))
sig = (Int(index(s)), finish(ctx))

push!(outp, (sig, pol))
Expand Down
18 changes: 10 additions & 8 deletions test/interfaces/nemo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
F = [x^2+1-3, x*y-z, x*z^2-3*y^2]
cmp = (Int32[2, 2, 2], BigInt[1, 1, -2, 1, 1, 1, -1, 1, 1, 1, -3, 1], Int32[2, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 2, 0, 2, 0])
@test AlgebraicSolving._convert_to_msolve(F) == cmp
R, (x,y,z) = polynomial_ring(GF(2147483659),["x","y","z"], ordering=:degrevlex)
F = [x^2+1-3, x*y-z, x*z^2-3*y^2]
# prime is bigger than 2^31, should throw an error
@test_throws ErrorException AlgebraicSolving._convert_to_msolve(F)
R, (x,y,z) = polynomial_ring(GF(101),["x","y","z"], ordering=:degrevlex)
F = [x^2+1-3, x*y-z, x*z^2-3*y^2]
res = AlgebraicSolving._convert_to_msolve(F)
@test AlgebraicSolving._convert_finite_field_array_to_abstract_algebra(Int32(3), res..., R) == F
for _GF in [GF, AlgebraicSolving.Nemo.Native.GF]
R, (x,y,z) = polynomial_ring(_GF(2147483659),["x","y","z"], ordering=:degrevlex)
F = [x^2+1-3, x*y-z, x*z^2-3*y^2]
# prime is bigger than 2^31, should throw an error
@test_throws ErrorException AlgebraicSolving._convert_to_msolve(F)
R, (x,y,z) = polynomial_ring(_GF(101),["x","y","z"], ordering=:degrevlex)
F = [x^2+1-3, x*y-z, x*z^2-3*y^2]
res = AlgebraicSolving._convert_to_msolve(F)
@test AlgebraicSolving._convert_finite_field_array_to_abstract_algebra(Int32(3), res..., R) == F
end
end

0 comments on commit 55f6b4e

Please sign in to comment.