Skip to content

Commit

Permalink
Merge pull request #38 from thofma/patch-2
Browse files Browse the repository at this point in the history
chore: adjust compat entry for Nemo and bump version
  • Loading branch information
ederc authored Jan 5, 2024
2 parents 40127ab + 4c2e1ee commit bf742aa
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 34 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), 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]
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{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), 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]
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{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{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), FqMPolyRingElem[x, y])
julia> I = Ideal([y*x^3+12-y, x+y])
fpMPolyRingElem[x^3*y + 100*y + 12, x + y]
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), FqMPolyRingElem[x, y])
julia> I = Ideal([y*x^3+12-y, x+y])
fpMPolyRingElem[x^3*y + 100*y + 12, x + y]
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{FqMPolyRingElem}:
2*x^2 + 7*x*y
x + y
julia> normal_form(F,I)
2-element Vector{fpMPolyRingElem}:
2-element Vector{FqMPolyRingElem}:
96*y^2
0
```
Expand Down
3 changes: 2 additions & 1 deletion src/exports.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export polynomial_ring, MPolyRing, GFElem, MPolyRingElem, finite_field, GF, fpMPolyRingElem,
characteristic, degree, ZZ, QQ, vars, nvars, ngens, ZZRingElem, QQFieldElem, QQMPolyRingElem,
base_ring, coefficient_ring, evaluate, prime_field, sig_groebner_basis, cyclic, leading_coefficient
base_ring, coefficient_ring, evaluate, prime_field, sig_groebner_basis, cyclic, leading_coefficient,
FqMPolyRingElem
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), 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]
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{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, FqMPolyRingElem}, 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

2 comments on commit bf742aa

@ederc
Copy link
Collaborator Author

@ederc ederc commented on bf742aa Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/98263

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.6 -m "<description of version>" bf742aa57ab0f3077e362ca246b274447f2ef5b8
git push origin v0.4.6

Please sign in to comment.