diff --git a/src/algorithms/groebner-bases.jl b/src/algorithms/groebner-bases.jl index ec2516f..f624adc 100644 --- a/src/algorithms/groebner-bases.jl +++ b/src/algorithms/groebner-bases.jl @@ -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 diff --git a/src/algorithms/solvers.jl b/src/algorithms/solvers.jl index 52ec1de..83704da 100644 --- a/src/algorithms/solvers.jl +++ b/src/algorithms/solvers.jl @@ -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) @@ -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)) @@ -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. @@ -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. diff --git a/src/imports.jl b/src/imports.jl index 3b7b113..a618961 100644 --- a/src/imports.jl +++ b/src/imports.jl @@ -31,6 +31,7 @@ import Nemo: is_probable_prime, is_square, is_unit, + is_zero, isqrtrem, jacobi_symbol, leading_coefficient, diff --git a/test/algorithms/solvers.jl b/test/algorithms/solvers.jl index fddc3f3..0cda5fc 100644 --- a/test/algorithms/solvers.jl +++ b/test/algorithms/solvers.jl @@ -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],