Skip to content

Commit

Permalink
Merge pull request #61 from ederc/handling-zero-ideal
Browse files Browse the repository at this point in the history
Handling zero ideal as input
  • Loading branch information
ederc authored Jun 27, 2024
2 parents 0145350 + 928c2fa commit 7f7ade5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/algorithms/groebner-bases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function _core_groebner_basis(

# convert ideal to flattened arrays of ints
if !(is_probable_prime(field_char))
error("At the moment we only supports finite fields.")
error("At the moment we only support finite fields.")
end

# nr_gens might change if F contains zero polynomials
Expand Down
9 changes: 6 additions & 3 deletions src/algorithms/solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ function _core_msolve(
)

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

res_ld = Ref(Cint(0))
res_nr_vars = Ref(Cint(0))
Expand Down Expand Up @@ -214,7 +217,7 @@ Given an ideal `I` with a finite solution set over the complex numbers, return
the rational parametrization of the ideal with a given precision (default 32 bits).
**Note**: At the moment only QQ is supported as ground field. If the dimension of the ideal
is greater then zero an empty array is returned.
is greater than zero an ErrorException is thrown.
# Arguments
- `I::Ideal{T} where T <: MPolyRingElem`: input generators.
Expand Down Expand Up @@ -364,7 +367,7 @@ Given an ideal `I` with a finite solution set over the complex numbers, return
the real roots of the ideal with a given precision (default 32 bits).
**Note**: At the moment only QQ is supported as ground field. If the dimension of the ideal
is greater than zero an empty array is returned.
is greater than zero an ErrorException is thrown.
# Arguments
- `I::Ideal{T} where T <: MPolyRingElem`: input generators.
Expand Down
1 change: 1 addition & 0 deletions src/imports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Nemo:
is_probable_prime,
is_square,
is_unit,
is_zero,
isqrtrem,
jacobi_symbol,
leading_coefficient,
Expand Down
8 changes: 7 additions & 1 deletion test/algorithms/solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@
@test_throws ErrorException real_solutions(I, interval=true)
@test_throws ErrorException rational_solutions(I)

# check variable permutation
R, (x, y) = polynomial_ring(QQ,["x","y"])
# issue 54
I = Ideal([R(0)])
@test_throws ErrorException real_solutions(I)
I = Ideal([x-1,y+2,R(0)])
@test sort(real_solutions(I)) == sort(Vector{QQFieldElem}[[1, -2]])

# check variable permutation
I = Ideal([x^2-1, y])
sols = Vector{QQFieldElem}[
[-1, 0],
Expand Down

0 comments on commit 7f7ade5

Please sign in to comment.