Skip to content

Commit ab2f709

Browse files
committed
first draft for rational_solutions function (simple case where no linear form was introduced
1 parent b54d72d commit ab2f709

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/algorithms/solvers.jl

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,51 @@ function rational_parametrization(
248248
return I.rat_param
249249
end
250250

251+
252+
function rational_solutions(
253+
I::Ideal{T} where T <: MPolyElem; # input generators
254+
initial_hts::Int=17, # hash table size, default 2^17
255+
nr_thrds::Int=1, # number of threads
256+
max_nr_pairs::Int=0, # number of pairs maximally chosen
257+
# in symbolic preprocessing
258+
la_option::Int=2, # linear algebra option
259+
info_level::Int=0, # info level for print outs
260+
precision::Int=32 # precision of the solution set
261+
)
262+
isdefined(I, :rat_param) ||
263+
_core_msolve(I,
264+
initial_hts = initial_hts,
265+
nr_thrds = nr_thrds,
266+
max_nr_pairs = max_nr_pairs,
267+
la_option = la_option,
268+
info_level = info_level,
269+
precision = precision)
270+
param_t = I.rat_param
271+
if length(param_t.vars) == parent(I).nvars
272+
nvars = length(param_t.vars)
273+
lpol = filter(l->degree(l) == 1, keys(factor(param_t.elim).fac))
274+
nb = length(lpol)
275+
276+
rat_elim = [-coeff(l, 0)// coeff(l, 1) for l in lpol]
277+
rat_den = map(l->evaluate(param_t.denom, l), rat_elim)
278+
rat_num = map(r->map(l->evaluate(l, r), param_t.param), rat_elim)
279+
280+
rat_sols = Vector{Vector{fmpq}}(undef, nb)
281+
282+
for i in 1:nb
283+
rat_sols[i] = Vector{fmpq}(undef, nvars)
284+
for j in 1:(nvars-1)
285+
rat_sols[i][j] = rat_num[i][j] // rat_den[i]
286+
end
287+
rat_sols[i][nvars] = rat_elim[i]
288+
end
289+
else
290+
println("Not implemented yet")
291+
return []
292+
end
293+
return rat_sols
294+
end
295+
251296
@doc Markdown.doc"""
252297
real_solutions(I::Ideal{T} where T <: MPolyElem, <keyword arguments>)
253298

0 commit comments

Comments
 (0)