Skip to content

Commit

Permalink
rename orderings: revlex->invlex,rp->ip...introduce deginvlex (#722)
Browse files Browse the repository at this point in the history
* rename orderings: revlex->invlex,rp->ip...introduce deginvlex

* add both variants

* Update src/poly/orderings.jl

Co-authored-by: Max Horn <max@quendi.de>

* fix: libSingular.rRingOrder_t

* solving conflict, update

* Set version to 0.20-DEV

* docs for orderings

currently we have both: ordering_ip and ordering_rp (also is/rs).
The description refers to the upcoming naming (invlex/ip)

---------

Co-authored-by: Max Horn <max@quendi.de>
  • Loading branch information
hannes14 and fingolfin authored Nov 7, 2023
1 parent 9d73872 commit 2b8a7d5
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Singular"
uuid = "bcd08a7b-43d2-5ff7-b6d4-c458787f915c"
version = "0.19.0"
version = "0.20.0-DEV"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
Expand Down
5 changes: 3 additions & 2 deletions deps/src/singular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ JLCXX_MODULE define_julia_module(jlcxx::Module & Singular)
/* monomial orderings */
Singular.set_const("ringorder_no", ringorder_no);
Singular.set_const("ringorder_lp", ringorder_lp);
Singular.set_const("ringorder_rp", ringorder_rp);
Singular.set_const("ringorder_ip", ringorder_ip);
Singular.set_const("ringorder_dp", ringorder_dp);
Singular.set_const("ringorder_Dp", ringorder_Dp);
Singular.set_const("ringorder_wp", ringorder_wp);
Singular.set_const("ringorder_Wp", ringorder_Wp);
Singular.set_const("ringorder_Ip", ringorder_Ip);
Singular.set_const("ringorder_ls", ringorder_ls);
Singular.set_const("ringorder_rs", ringorder_rs);
Singular.set_const("ringorder_is", ringorder_is);
Singular.set_const("ringorder_ds", ringorder_ds);
Singular.set_const("ringorder_Ds", ringorder_Ds);
Singular.set_const("ringorder_ws", ringorder_ws);
Expand Down
12 changes: 12 additions & 0 deletions docs/src/polynomial.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ following block orderings.
ordering_lp(nvars::Int = 1)
```

```@docs
ordering_ip(nvars::Int = 1)
```

```@docs
ordering_rp(nvars::Int = 1)
```
Expand All @@ -169,10 +173,18 @@ ordering_wp(w::Vector{Int})
ordering_Wp(w::Vector{Int})
```

```@docs
ordering_Ip(nvars::Int = 1)
```

```@docs
ordering_ls(nvars::Int = 1)
```

```@docs
ordering_is(nvars::Int = 1)
```

```@docs
ordering_rs(nvars::Int = 1)
```
Expand Down
10 changes: 6 additions & 4 deletions src/Singular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,14 @@ function __init__()

global ringorder_no = libSingular.ringorder_no
global ringorder_lp = libSingular.ringorder_lp
global ringorder_rp = libSingular.ringorder_rp
global ringorder_ip = libSingular.ringorder_ip
global ringorder_dp = libSingular.ringorder_dp
global ringorder_Dp = libSingular.ringorder_Dp
global ringorder_wp = libSingular.ringorder_wp
global ringorder_Wp = libSingular.ringorder_Wp
global ringorder_Ip = libSingular.ringorder_Ip
global ringorder_ls = libSingular.ringorder_ls
global ringorder_rs = libSingular.ringorder_rs
global ringorder_is = libSingular.ringorder_is
global ringorder_ds = libSingular.ringorder_ds
global ringorder_Ds = libSingular.ringorder_Ds
global ringorder_ws = libSingular.ringorder_ws
Expand All @@ -154,11 +155,12 @@ function __init__()

global sym2ringorder = Dict{Symbol, libSingular.rRingOrder_t}(
:lex => ringorder_lp,
:revlex => ringorder_rp,
:invlex => ringorder_ip,
:neglex => ringorder_ls,
:negrevlex => ringorder_rs,
:neginvlex => ringorder_is,
:degrevlex => ringorder_dp,
:deglex => ringorder_Dp,
:deginvlex => ringorder_Ip,
:negdegrevlex => ringorder_ds,
:negdeglex => ringorder_Ds,
:comp1max => ringorder_c,
Expand Down
87 changes: 68 additions & 19 deletions src/poly/orderings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function AbstractAlgebra.expressify(a::sordering; context = nothing)
for i in a.data
if i.order == ringorder_lp
this = Expr(:call, :ordering_lp, i.size)
elseif i.order == ringorder_rp
this = Expr(:call, :ordering_rp, i.size)
elseif i.order == ringorder_ip
this = Expr(:call, :ordering_ip, i.size)
elseif i.order == ringorder_dp
this = Expr(:call, :ordering_dp, i.size)
elseif i.order == ringorder_Dp
Expand All @@ -19,10 +19,12 @@ function AbstractAlgebra.expressify(a::sordering; context = nothing)
this = Expr(:call, :ordering_wp, string(i.weights))
elseif i.order == ringorder_Wp
this = Expr(:call, :ordering_Wp, string(i.weights))
elseif i.order == ringorder_Ip
this = Expr(:call, :ordering_Ip, i.size)
elseif i.order == ringorder_ls
this = Expr(:call, :ordering_ls, i.size)
elseif i.order == ringorder_rs
this = Expr(:call, :ordering_rs, i.size)
elseif i.order == ringorder_is
this = Expr(:call, :ordering_is, i.size)
elseif i.order == ringorder_ds
this = Expr(:call, :ordering_ds, i.size)
elseif i.order == ringorder_Ds
Expand Down Expand Up @@ -61,9 +63,10 @@ end

function _is_basic_ordering(t::libSingular.rRingOrder_t)
return t == ringorder_lp || t == ringorder_ls ||
t == ringorder_rp || t == ringorder_rs ||
t == ringorder_ip || t == ringorder_is ||
t == ringorder_dp || t == ringorder_ds ||
t == ringorder_Dp || t == ringorder_Ds
t == ringorder_Dp || t == ringorder_Ds ||
t == ringorder_Ip
end

function _is_weighted_ordering(t::libSingular.rRingOrder_t)
Expand Down Expand Up @@ -94,31 +97,43 @@ end
ordering_lp(nvars::Int = 1)
Represents a block of at least `nvars` variables with the
lexicographical ordering (:lex).
lexicographical ordering (:lex) (the Singular ordering `lp`).
"""
ordering_lp(nvars::Int = 1) = _basic_ordering(Singular.ringorder_lp, nvars)

@doc raw"""
ordering_rp(nvars::Int = 1)
Represents a block of at least `nvars` variables with the
reverse lexicographical ordering (:revlex).
inverse lexicographical ordering (:invlex) (the Singular ordering `ip`).
Note that this reverses the "natural" order `x_1 > ... > x_n`.
"""
ordering_rp(nvars::Int = 1) = _basic_ordering(Singular.ringorder_ip, nvars)

@doc raw"""
ordering_ip(nvars::Int = 1)
Represents a block of at least `nvars` variables with the Singular ordering `ip`.
This stands for what the Singular manual refers to as "reverse lexicographical ordering" (and is elsewhere sometimes called "inverse lexicographical ordering), i.e. a lexicographical ordering from the right with `1 < x_1 < ... <x_n`.
Note that this reverses the "natural" order `x_1 > ... > x_n`.
"""
ordering_rp(nvars::Int = 1) = _basic_ordering(Singular.ringorder_rp, nvars)
ordering_ip(nvars::Int = 1) = _basic_ordering(Singular.ringorder_ip, nvars)

@doc raw"""
ordering_dp(nvars::Int = 1)
Represents a block of at least `nvars` variables with the
degree reverse lexicographical ordering (:degrevlex).
degree reverse lexicographical ordering (:degrevlex) (the Singular ordering `dp`).
"""
ordering_dp(nvars::Int = 1) = _basic_ordering(Singular.ringorder_dp, nvars)

@doc raw"""
ordering_Dp(nvars::Int = 1)
Represents a block of at least `nvars` variables with the
degree lexicographical ordering (:deglex).
degree lexicographical ordering (:deglex) (the Singular ordering `Dp`).
"""
ordering_Dp(nvars::Int = 1) = _basic_ordering(Singular.ringorder_Dp, nvars)

Expand All @@ -128,6 +143,7 @@ ordering_Dp(nvars::Int = 1) = _basic_ordering(Singular.ringorder_Dp, nvars)
Represents a block of variables with the
weighted reverse lexicographical ordering.
The weight vector `w` is expected to consist of positive integers only.
(the Singular ordering `wp`).
"""
ordering_wp(w::Vector{Int}) = _global_weighted_ordering(Singular.ringorder_wp, w)

Expand All @@ -137,30 +153,54 @@ ordering_wp(w::Vector{Int}) = _global_weighted_ordering(Singular.ringorder_wp, w
Represents a block of variables with the
weighted lexicographical ordering.
The weight vector is expected to consist of positive integers only.
(the Singular ordering `Wp`).
"""
ordering_Wp(w::Vector{Int}) = _global_weighted_ordering(Singular.ringorder_Wp, w)

@doc raw"""
ordering_Ip(nvars::Int = 1)
Represents a block of at least `nvars` variables with the
degree inverse lexicographical ordering (:deginvlex) (the Singular ordering `Ip`).
Note that this reverses the "natural" order `x_1 > ... > x_n`.
"""
ordering_Ip(nvars::Int = 1) = _basic_ordering(Singular.ringorder_Ip, nvars)

@doc raw"""
ordering_ls(nvars::Int = 1)
Represents a block of at least `nvars` variables with the
negative lexicographical ordering (:neglex).
negative lexicographical ordering (:neglex) (the Singular ordering `ls`).
"""
ordering_ls(nvars::Int = 1) = _basic_ordering(Singular.ringorder_ls, nvars)

@doc raw"""
ordering_rs(nvars::Int = 1)
Represents a block of at least `nvars` variables with the
negative reverse lexicographical ordering (:negrevlex).
negative inverse lexicographical ordering (:neginvlex) (the Singular ordering `is`)
Note that this reverses the "natural" order `x_1 > ... > x_n`.
"""
ordering_rs(nvars::Int = 1) = _basic_ordering(Singular.ringorder_is, nvars)

@doc raw"""
ordering_is(nvars::Int = 1)
Represents a block of at least `nvars` variables with the
negative inverse lexicographical ordering (:neginvlex) (the Singular ordering `is`)
Note that this reverses the "natural" order `x_1 > ... > x_n`.
"""
ordering_rs(nvars::Int = 1) = _basic_ordering(Singular.ringorder_rs, nvars)
ordering_is(nvars::Int = 1) = _basic_ordering(Singular.ringorder_is, nvars)

@doc raw"""
ordering_ds(nvars::Int = 1)
Represents a block of at least `nvars` variables with the
negative degree reverse lexicographical ordering (:negdegrevlex).
negative degree reverse lexicographical ordering (:negdegrevlex)
(the Singular ordering `ds`).
"""
ordering_ds(nvars::Int = 1) = _basic_ordering(Singular.ringorder_ds, nvars)

Expand All @@ -169,6 +209,7 @@ ordering_ds(nvars::Int = 1) = _basic_ordering(Singular.ringorder_ds, nvars)
Represents a block of at least `nvars` variables with the
negative degree reverse lexicographical ordering (:negdeglex).
(the Singular ordering `Ds`).
"""
ordering_Ds(nvars::Int = 1) = _basic_ordering(Singular.ringorder_Ds, nvars)

Expand All @@ -178,6 +219,7 @@ ordering_Ds(nvars::Int = 1) = _basic_ordering(Singular.ringorder_Ds, nvars)
Represents a block of variables with the
general weighted reverse lexicographical ordering.
The weight vector `w` is expected to have a nonzero first entry.
(the Singular ordering `ws`).
"""
ordering_ws(w::Vector{Int}) = _local_weighted_ordering(Singular.ringorder_ws, w)

Expand All @@ -187,6 +229,7 @@ ordering_ws(w::Vector{Int}) = _local_weighted_ordering(Singular.ringorder_ws, w)
Represents a block of variables with the
general weighted lexicographical ordering.
The weight vector `w` is expected to have a nonzero first entry.
(the Singular ordering `Ws`).
"""
ordering_Ws(w::Vector{Int}) = _local_weighted_ordering(Singular.ringorder_Ws, w)

Expand All @@ -197,6 +240,7 @@ Represents an extra weight vector that may precede any monomial ordering.
An extra weight vector does not define a monomial ordering by itself: it can
only be used in combination with other orderings to insert an extra line of
weights into the ordering matrix.
(the Singular ordering `a`).
"""
ordering_a(w::Vector{Int}) = sordering([sorder_block(ringorder_a, 0, w)])

Expand All @@ -205,6 +249,7 @@ ordering_a(w::Vector{Int}) = sordering([sorder_block(ringorder_a, 0, w)])
Represents a block of variables with a general matrix ordering.
The matrix `m` is expected to be invertible, and this is checked by default.
(the Singular ordering `M`).
"""
function ordering_M(m::Matrix{Int}; check::Bool=true)
(nr, nc) = size(m)
Expand All @@ -228,6 +273,7 @@ All monomial block orderings preceding the component ordering have higher
precedence, and all succeeding monomial block orderings have lower precedence.
It is not necessary to specify this ordering explicitly since it appended
automatically to an ordering lacking a component specification.
(the Singular ordering `C`).
"""
ordering_C(dummy::Int = 0) = _basic_ordering(Singular.ringorder_C, 0)

Expand All @@ -237,6 +283,7 @@ ordering_C(dummy::Int = 0) = _basic_ordering(Singular.ringorder_C, 0)
Represents a descending ordering on vector components `gen(1) > gen(2) > ...`.
All monomial block orderings preceding the component ordering have higher
precedence, and all succeeding monomial block orderings have lower precedence.
(the Singular ordering `c`).
"""
ordering_c(dummy::Int = 0) = _basic_ordering(Singular.ringorder_c, 0)

Expand Down Expand Up @@ -302,16 +349,18 @@ function is_ordering_symbolic_with_symbol(a::sordering)
o = a.data[1].order
if o == ringorder_lp
return (true, :lex)
elseif o == ringorder_rp
return (true, :revlex)
elseif o == ringorder_ip
return (true, :invlex)
elseif o == ringorder_ls
return (true, :neglex)
elseif o == ringorder_rs
return (true, :negrevlex)
elseif o == ringorder_is
return (true, :neginvlex)
elseif o == ringorder_dp
return (true, :degrevlex)
elseif o == ringorder_Dp
return (true, :deglex)
elseif o == ringorder_Ip
return (true, :deginvlex)
elseif o == ringorder_ds
return (true, :negdegrevlex)
elseif o == ringorder_Ds
Expand Down
7 changes: 4 additions & 3 deletions src/poly/poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ export spoly, PolyRing, change_base_ring, coeff, coefficients,
tail, terms, total_degree, trailing_coefficient,
valuation, var_index, vars

export ordering_lp, ordering_rp, ordering_dp, ordering_Dp, ordering_wp, ordering_Wp,
ordering_ls, ordering_rs, ordering_ds, ordering_Ds, ordering_ws, ordering_Ws,
ordering_a, ordering_M, ordering_c, ordering_C, ordering_s, ordering_S
export ordering_lp, ordering_ip, ordering_dp, ordering_Dp, ordering_wp, ordering_Wp,
ordering_ls, ordering_is, ordering_ds, ordering_Ds, ordering_ws, ordering_Ws,
ordering_a, ordering_M, ordering_c, ordering_C, ordering_s, ordering_S,
ordering_Ip, ordering_rp, ordering_rs


###############################################################################
Expand Down
8 changes: 4 additions & 4 deletions test/poly/PolyRing-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ end


R, (x1, x2, x3, x4) = polynomial_ring(QQ, "x".*string.(1:4), ordering =
ordering_Wp([1, 2])*ordering_rp())
test_ordering(ordering(R), [:wdeglex, :revlex, :comp1min],
ordering_Wp([1, 2])*ordering_ip())
test_ordering(ordering(R), [:wdeglex, :invlex, :comp1min],
[2, 2, 0],
[Int[1, 2], Int[], Int[]])
test_monomials([x2^3, x1*x2^2, x1^2*x2, x2^2*x4, x2^2*x3, x2^2, x1^3,
Expand All @@ -110,8 +110,8 @@ end


R, (x1, x2, x3, x4) = polynomial_ring(QQ, "x".*string.(1:4), ordering =
ordering_rs(2)*ordering_wp([1, 2]))
test_ordering(ordering(R), [:negrevlex, :wdegrevlex, :comp1min],
ordering_is(2)*ordering_wp([1, 2]))
test_ordering(ordering(R), [:neginvlex, :wdegrevlex, :comp1min],
[2, 2, 0],
[Int[], Int[1, 2], Int[]])
test_monomials([x4^3, x3*x4^2, x3^2*x4, x4^2, x3^3, x3*x4, x3^2, x4, x3,
Expand Down

0 comments on commit 2b8a7d5

Please sign in to comment.