Skip to content

Commit 0349fe2

Browse files
committed
Add block orderings
1 parent a50ad32 commit 0349fe2

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

src/algorithms/groebner-bases.jl

Lines changed: 19 additions & 7 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,
54-
max_nr_pairs=max_nr_pairs, la_option=la_option,
55-
eliminate=eliminate,
56+
return groebner_basis(I, initial_hts=initial_hts,nr_thrds=nr_thrds,
57+
max_nr_pairs=max_nr_pairs, la_option=la_option,
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,15 @@ 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+
println(intersect)
180+
if intersect == true
181+
basis = _convert_finite_field_array_to_abstract_algebra(
182+
jl_ld, jl_len, jl_cf, jl_exp, R, eliminate)
183+
else
184+
println("Hi")
185+
basis = _convert_finite_field_array_to_abstract_algebra(
186+
jl_ld, jl_len, jl_cf, jl_exp, R, 0)
187+
end
176188

177189
ccall((:free_f4_julia_result_data, libneogb), Nothing ,
178190
(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)