Skip to content

Commit 7f7ade5

Browse files
authored
Merge pull request #61 from ederc/handling-zero-ideal
Handling zero ideal as input
2 parents 0145350 + 928c2fa commit 7f7ade5

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

src/algorithms/groebner-bases.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function _core_groebner_basis(
150150

151151
# convert ideal to flattened arrays of ints
152152
if !(is_probable_prime(field_char))
153-
error("At the moment we only supports finite fields.")
153+
error("At the moment we only support finite fields.")
154154
end
155155

156156
# nr_gens might change if F contains zero polynomials

src/algorithms/solvers.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ function _core_msolve(
6565
)
6666

6767
F = I.gens
68+
if (is_zero(F))
69+
error("Dimension of ideal is greater than zero, no solutions provided.")
70+
end
6871
R = first(F).parent
6972
nr_vars = nvars(R)
7073
nr_gens = length(F)
@@ -86,7 +89,7 @@ function _core_msolve(
8689
error("At the moment we only support the rationals as ground field.")
8790
end
8891
# convert Singular ideal to flattened arrays of ints
89-
lens, cfs, exps = _convert_to_msolve(F)
92+
lens, cfs, exps, nr_gens = _convert_to_msolve(F)
9093

9194
res_ld = Ref(Cint(0))
9295
res_nr_vars = Ref(Cint(0))
@@ -214,7 +217,7 @@ Given an ideal `I` with a finite solution set over the complex numbers, return
214217
the rational parametrization of the ideal with a given precision (default 32 bits).
215218
216219
**Note**: At the moment only QQ is supported as ground field. If the dimension of the ideal
217-
is greater then zero an empty array is returned.
220+
is greater than zero an ErrorException is thrown.
218221
219222
# Arguments
220223
- `I::Ideal{T} where T <: MPolyRingElem`: input generators.
@@ -364,7 +367,7 @@ Given an ideal `I` with a finite solution set over the complex numbers, return
364367
the real roots of the ideal with a given precision (default 32 bits).
365368
366369
**Note**: At the moment only QQ is supported as ground field. If the dimension of the ideal
367-
is greater than zero an empty array is returned.
370+
is greater than zero an ErrorException is thrown.
368371
369372
# Arguments
370373
- `I::Ideal{T} where T <: MPolyRingElem`: input generators.

src/imports.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import Nemo:
3131
is_probable_prime,
3232
is_square,
3333
is_unit,
34+
is_zero,
3435
isqrtrem,
3536
jacobi_symbol,
3637
leading_coefficient,

test/algorithms/solvers.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,14 @@
6161
@test_throws ErrorException real_solutions(I, interval=true)
6262
@test_throws ErrorException rational_solutions(I)
6363

64-
# check variable permutation
6564
R, (x, y) = polynomial_ring(QQ,["x","y"])
65+
# issue 54
66+
I = Ideal([R(0)])
67+
@test_throws ErrorException real_solutions(I)
68+
I = Ideal([x-1,y+2,R(0)])
69+
@test sort(real_solutions(I)) == sort(Vector{QQFieldElem}[[1, -2]])
70+
71+
# check variable permutation
6672
I = Ideal([x^2-1, y])
6773
sols = Vector{QQFieldElem}[
6874
[-1, 0],

0 commit comments

Comments
 (0)