Skip to content

Commit 40a4f18

Browse files
authored
Merge pull request #59 from linus-md/block
Add block orderings
2 parents a50ad32 + a7c8bd0 commit 40a4f18

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

docs/src/groebner-bases.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ well as a signature based algorithm to compute Gröbner bases.
3434
max_nr_pairs::Int=0,
3535
la_option::Int=2,
3636
eliminate::Int=0,
37+
intersect::Bool=true,
3738
complete_reduction::Bool=true,
3839
info_level::Int=0
3940
)
@@ -43,12 +44,15 @@ The engine supports the elimination of one block of variables considering the
4344
product monomial ordering of two blocks, both ordered w.r.t. the degree
4445
reverse lexicographical order. One can either directly add the number of
4546
variables of the first block via the `eliminate` parameter in the
46-
`groebner_basis` call. We have also implemented an alias for this call:
47+
`groebner_basis` call. By using `intersect=false` it is possible to only
48+
use block ordering without intersecting. We have also implemented an alias
49+
for this call:
4750

4851
```@docs
4952
eliminate(
5053
I::Ideal{T} where T <: MPolyRingElem,
5154
eliminate::Int;
55+
intersect::Bool=true,
5256
initial_hts::Int=17,
5357
nr_thrds::Int=1,
5458
max_nr_pairs::Int=0,

src/algorithms/groebner-bases.jl

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ At the moment the underlying algorithm is based on variants of Faugère's F4 Alg
1515
1616
# Arguments
1717
- `I::Ideal{T} where T <: MPolyRingElem`: input generators.
18+
- `eliminate::Int=0`: size of first block of variables to be eliminated.
19+
- `intersect::Bool=true`: compute the `eliminate`-th elimination ideal.
1820
- `initial_hts::Int=17`: initial hash table size `log_2`.
1921
- `nr_thrds::Int=1`: number of threads for parallel linear algebra.
2022
- `max_nr_pairs::Int=0`: maximal number of pairs per matrix, only bounded by minimal degree if `0`.
@@ -40,6 +42,7 @@ julia> eliminate(I, 2)
4042
function eliminate(
4143
I::Ideal{T} where T <: MPolyRingElem,
4244
eliminate::Int;
45+
intersect::Bool=true,
4346
initial_hts::Int=17,
4447
nr_thrds::Int=1,
4548
max_nr_pairs::Int=0,
@@ -50,9 +53,9 @@ function eliminate(
5053
if eliminate <= 0
5154
error("Number of variables to be eliminated is <= 0.")
5255
else
53-
return groebner_basis(I, initial_hts=initial_hts, nr_thrds=nr_thrds,
56+
return groebner_basis(I, initial_hts=initial_hts,nr_thrds=nr_thrds,
5457
max_nr_pairs=max_nr_pairs, la_option=la_option,
55-
eliminate=eliminate,
58+
eliminate=eliminate, intersect=intersect,
5659
complete_reduction=complete_reduction,
5760
info_level=info_level)
5861
end
@@ -73,6 +76,7 @@ At the moment the underlying algorithm is based on variants of Faugère's F4 Alg
7376
- `max_nr_pairs::Int=0`: maximal number of pairs per matrix, only bounded by minimal degree if `0`.
7477
- `la_option::Int=2`: linear algebra option: exact sparse-dense (`1`), exact sparse (`2`, default), probabilistic sparse-dense (`42`), probabilistic sparse(`44`).
7578
- `eliminate::Int=0`: size of first block of variables to be eliminated.
79+
- `intersect::Bool=true`: compute the `eliminate`-th elimination ideal.
7680
- `complete_reduction::Bool=true`: compute a reduced Gröbner basis for `I`
7781
- `info_level::Int=0`: info level printout: off (`0`, default), summary (`1`), detailed (`2`).
7882
@@ -105,14 +109,15 @@ function groebner_basis(
105109
max_nr_pairs::Int=0,
106110
la_option::Int=2,
107111
eliminate::Int=0,
112+
intersect::Bool=true,
108113
complete_reduction::Bool=true,
109114
info_level::Int=0
110115
)
111116

112117
return get!(I.gb, eliminate) do
113118
_core_groebner_basis(I, initial_hts = initial_hts, nr_thrds = nr_thrds,
114119
max_nr_pairs = max_nr_pairs, la_option = la_option,
115-
eliminate = eliminate,
120+
eliminate = eliminate, intersect = intersect,
116121
complete_reduction = complete_reduction,
117122
info_level = info_level)
118123
end
@@ -125,6 +130,7 @@ function _core_groebner_basis(
125130
max_nr_pairs::Int=0,
126131
la_option::Int=2,
127132
eliminate::Int=0,
133+
intersect::Bool=true,
128134
complete_reduction::Bool=true,
129135
info_level::Int=0
130136
)
@@ -170,9 +176,13 @@ function _core_groebner_basis(
170176
ptr = reinterpret(Ptr{Int32}, gb_cf[])
171177
jl_cf = Base.unsafe_wrap(Array, ptr, nr_terms)
172178

173-
basis = _convert_finite_field_array_to_abstract_algebra(
174-
jl_ld, jl_len, jl_cf, jl_exp, R, eliminate)
175-
179+
if intersect == true
180+
basis = _convert_finite_field_array_to_abstract_algebra(
181+
jl_ld, jl_len, jl_cf, jl_exp, R, eliminate)
182+
else
183+
basis = _convert_finite_field_array_to_abstract_algebra(
184+
jl_ld, jl_len, jl_cf, jl_exp, R, 0)
185+
end
176186

177187
ccall((:free_f4_julia_result_data, libneogb), Nothing ,
178188
(Ptr{Nothing}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cint}},

test/algorithms/groebner-bases.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020
z^4 + 38*z^3 + 95*z^2 + 95*z
2121
]
2222
@test G == H
23+
24+
I = Ideal([x+2*y+2*z-1, x^2+2*y^2+2*z^2-x, 2*x*y+2*y*z-y])
25+
G = groebner_basis(I, eliminate=2, intersect=false)
26+
H = MPolyRingElem[
27+
z^4 + 38*z^3 + 95*z^2 + 95*z
28+
30*z^3 + 32*z^2 + y + 87*z
29+
41*z^3 + 37*z^2 + x + 30*z + 100
30+
]
31+
@test G == H
2332

2433
@test_throws ErrorException eliminate(I,0)
2534
L = eliminate(I,2)

0 commit comments

Comments
 (0)