Skip to content
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

first small step in fixing the orderings #1427

Merged
merged 3 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Modules/missing_functionality.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function lift(f::MPolyElem, I::MPolyIdeal, o::MonomialOrdering)
iszero(f) && return zero(MatrixSpace(base_ring(I), 1, ngens(I)))
R = parent(f)
R == base_ring(I) || error("polynomial does not belong to the base ring of the ideal")
Rsing = singular_poly_ring(R, o.o)
Rsing = singular_poly_ring(R, o)
fsing = Singular.Ideal(Rsing, [Rsing(f)])
gsing = Singular.Ideal(Rsing, Rsing.(gens(I)))
a_s, rem_s, u_s = lift(gsing, fsing, false, false, false)
Expand Down
2 changes: 1 addition & 1 deletion src/Rings/mpoly-graded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ end

function singular_poly_ring(R::MPolyRing_dec; keep_ordering::Bool = false)
if !keep_ordering
return singular_poly_ring(R.R, default_ordering(R).o)
return singular_poly_ring(R.R, default_ordering(R))
end
return singular_poly_ring(R.R, keep_ordering = keep_ordering)
end
Expand Down
6 changes: 3 additions & 3 deletions src/Rings/mpoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ end
singular(ord::MonomialOrdering) = singular(ord.o)
singular(ord::ModuleOrdering) = singular(ord.o)

function singular_poly_ring(Rx::MPolyRing{T}, ord::Orderings.AbsOrdering) where {T <: RingElem}
function singular_poly_ring(Rx::MPolyRing{T}, ord::MonomialOrdering) where {T <: RingElem}
return Singular.PolynomialRing(singular_coeff_ring(base_ring(Rx)),
[string(x) for x = Nemo.symbols(Rx)],
ordering = singular(ord),
Expand Down Expand Up @@ -571,7 +571,7 @@ end
function singular_assure(I::BiPolyArray, ordering::MonomialOrdering)
if !isdefined(I, :S) 
I.ord = ordering.o
I.Sx = singular_poly_ring(I.Ox, ordering.o)
I.Sx = singular_poly_ring(I.Ox, ordering)
I.S = Singular.Ideal(I.Sx, elem_type(I.Sx)[I.Sx(x) for x = I.O])
if I.isGB
I.S.isGB = true
Expand All @@ -581,7 +581,7 @@ function singular_assure(I::BiPolyArray, ordering::MonomialOrdering)
= attached, thus we have to create a new singular ring and map the ideal. =#
if !isdefined(I, :ord) || I.ord != ordering.o
I.ord = ordering.o
SR = singular_poly_ring(I.Ox, ordering.o)
SR = singular_poly_ring(I.Ox, ordering)
f = Singular.AlgebraHomomorphism(I.Sx, SR, gens(SR))
I.S = Singular.map_ideal(f, I.S)
I.Sx = SR
Expand Down
4 changes: 2 additions & 2 deletions src/Rings/orderings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function weights(a::GenOrdering)
end
if a.ord == :negdeglex || a.ord == Symbol("Singular(Ds)")
return [-matrix(ZZ, 1, length(a.vars), ones(fmpz, length(a.vars)));
-identity_matrix(ZZ, length(a.vars)-1) zero_matrix(ZZ, length(a.vars)-1, 1)]
identity_matrix(ZZ, length(a.vars)-1) zero_matrix(ZZ, length(a.vars)-1, 1)]
end
if a.ord == :negdegrevlex || a.ord == Symbol("Singular(ds)")
return [-matrix(ZZ, 1, length(a.vars), ones(fmpz, length(a.vars))) ;
Expand All @@ -155,7 +155,7 @@ function weights(a::GenOrdering)
end
if a.ord == :negwdeglex || a.ord == Symbol("Singular(Ws)")
return [-matrix(ZZ, 1, length(a.vars), a.w);
-identity_matrix(ZZ, length(a.vars)-1) zero_matrix(ZZ, length(a.vars)-1, 1)]
identity_matrix(ZZ, length(a.vars)-1) zero_matrix(ZZ, length(a.vars)-1, 1)]
end
if a.ord == :negwdegrevlex || a.ord == Symbol("Singular(ws)")
return [-matrix(ZZ, 1, length(a.vars), a.w);
Expand Down
7 changes: 6 additions & 1 deletion test/Rings/orderings-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ end
@test negdeglex([x, y, z]) == negwdeglex([x, y, z], [1, 1, 1])
@test negdegrevlex([x, y, z]) == negwdegrevlex([x, y, z], [1, 1, 1])
@test neglex([z])*neglex([y])*neglex([x]) == negrevlex([x, y, z])

m = matrix(ZZ, [-1 -1 -1; 1 0 0; 0 1 0; 0 0 1])
@test negdeglex(gens(R)) == matrix_ordering(gens(R), m)

m = matrix(ZZ, [-2 -3 -4; 1 0 0; 0 1 0; 0 0 1])
@test negwdeglex(gens(R), [2, 3, 4]) == matrix_ordering(gens(R), m)
end

@testset "Polynomial Orderings sorting" begin
Expand All @@ -110,7 +116,6 @@ end
o = negrevlex([x1, x2])*wdegrevlex([x3, x4], [1, 2])
@test collect(monomials(f, o)) == M

# currently fails
M = [one(R), x3, x3^2, x4, x3^3, x3*x4, x3^2*x4, x4^2, x3*x4^2,
x4^3, x2, x2*x3, x2*x3^2, x2*x4, x2*x3*x4, x2*x4^2, x2^2, x2^2*x3,
x2^2*x4, x2^3, x1, x1*x3, x1*x3^2, x1*x4, x1*x3*x4, x1*x4^2, x1*x2,
Expand Down