11import msolve_jll: libmsolve
22
3- export inter_solutions, real_solutions, rational_solutions, rational_parametrization
3+ export real_solutions, rational_solutions, rational_parametrization
44
55@doc Markdown. doc"""
66 _get_rational_parametrization(nr::Int32, lens::Vector{Int32}, cfs::Ptr{BigInt})
@@ -374,6 +374,7 @@ is greater than zero an empty array is returned.
374374- `la_option::Int=2`: linear algebra option: exact sparse-dense (`1`), exact sparse (`2`, default), probabilistic sparse-dense (`42`), probabilistic sparse(`44`).
375375- `info_level::Int=0`: info level printout: off (`0`, default), summary (`1`), detailed (`2`).
376376- `precision::Int=32`: bit precision for the computed solutions.
377+ - `interval::Bool=false`: return real solutions as intervals.
377378
378379# Examples
379380```jldoctest
@@ -391,6 +392,13 @@ julia> real_solutions(I)
391392 [1, 0, 0]
392393 [1945971683//8589934592, 972985841//8589934592, 744426424910260862653434112767010536665//2722258935367507707706996859454145691648]
393394 [2863311531//8589934592, 0, 3629678580490010276942662479272194255531//10889035741470030830827987437816582766592]
395+
396+ julia> real_solutions(I, interval=true)
397+ 4-element Vector{Vector{Vector{QQFieldElem}}}:
398+ [[1354207349//2147483648, 2708414699//4294967296], [1354207349//4294967296, 677103675//2147483648], [-355532291286331190123863132844989723573//2722258935367507707706996859454145691648, -1422129165145324760495452531379958894291//10889035741470030830827987437816582766592]]
399+ [[1, 1], [0, 0], [0, 0]]
400+ [[972985841//4294967296, 486492921//2147483648], [60811615//536870912, 486492921//4294967296], [93053303113782607831679264095876317083//340282366920938463463374607431768211456, 372213212455130431326717056383505268333//1361129467683753853853498429727072845824]]
401+ [[1431655765//4294967296, 715827883//2147483648], [-1//4294967296, 1//4294967296], [1814839290245005138471331239636097127765//5444517870735015415413993718908291383296, 907419645122502569235665619818048563883//2722258935367507707706996859454145691648]]
394402```
395403"""
396404function real_solutions (
@@ -401,7 +409,8 @@ function real_solutions(
401409 # in symbolic preprocessing
402410 la_option:: Int = 2 , # linear algebra option
403411 info_level:: Int = 0 , # info level for print outs
404- precision:: Int = 32 # precision of the solution set
412+ precision:: Int = 32 , # precision of the solution set
413+ interval:: Bool = false # return real solutions as intervals
405414 )
406415
407416 isdefined (I, :real_sols ) ||
@@ -413,64 +422,9 @@ function real_solutions(
413422 info_level = info_level,
414423 precision = precision)
415424
416- return I. real_sols
417- end
418-
419- @doc Markdown. doc"""
420- inter_solutions(I::Ideal{T} where T <: MPolyRingElem, <keyword arguments>)
421-
422- Given an ideal `I` with a finite solution set over the complex numbers, return
423- the intervals with a given precision (default 32 bits), containing the roots of the ideal.
424-
425- **Note**: At the moment only QQ is supported as ground field. If the dimension of the ideal
426- is greater than zero an empty array is returned.
427-
428- # Arguments
429- - `I::Ideal{T} where T <: MPolyRingElem`: input generators.
430- - `initial_hts::Int=17`: initial hash table size `log_2`.
431- - `nr_thrds::Int=1`: number of threads for parallel linear algebra.
432- - `max_nr_pairs::Int=0`: maximal number of pairs per matrix, only bounded by minimal degree if `0`.
433- - `la_option::Int=2`: linear algebra option: exact sparse-dense (`1`), exact sparse (`2`, default), probabilistic sparse-dense (`42`), probabilistic sparse(`44`).
434- - `info_level::Int=0`: info level printout: off (`0`, default), summary (`1`), detailed (`2`).
435- - `precision::Int=32`: bit precision for the computed solutions.
436-
437- # Examples
438- ```jldoctest
439- julia> using AlgebraicSolving
440-
441- julia> R,(x1,x2,x3) = polynomial_ring(QQ, ["x1","x2","x3"])
442- (Multivariate polynomial ring in 3 variables over QQ, QQMPolyRingElem[x1, x2, x3])
443-
444- julia> I = Ideal([x1+2*x2+2*x3-1, x1^2+2*x2^2+2*x3^2-x1, 2*x1*x2+2*x2*x3-x2])
445- QQMPolyRingElem[x1 + 2*x2 + 2*x3 - 1, x1^2 - x1 + 2*x2^2 + 2*x3^2, 2*x1*x2 + 2*x2*x3 - x2]
446-
447- julia> inter_solutions(I)
448- 4-element Vector{Vector{Vector{QQFieldElem}}}:
449- [[1354207349//2147483648, 2708414699//4294967296], [1354207349//4294967296, 677103675//2147483648], [-355532291286331190123863132844989723573//2722258935367507707706996859454145691648, -1422129165145324760495452531379958894291//10889035741470030830827987437816582766592]]
450- [[1, 1], [0, 0], [0, 0]]
451- [[972985841//4294967296, 486492921//2147483648], [60811615//536870912, 486492921//4294967296], [93053303113782607831679264095876317083//340282366920938463463374607431768211456, 372213212455130431326717056383505268333//1361129467683753853853498429727072845824]]
452- [[1431655765//4294967296, 715827883//2147483648], [-1//4294967296, 1//4294967296], [1814839290245005138471331239636097127765//5444517870735015415413993718908291383296, 907419645122502569235665619818048563883//2722258935367507707706996859454145691648]]
453- ```
454- """
455- function inter_solutions (
456- I:: Ideal{T} where T <: MPolyRingElem ; # input generators
457- initial_hts:: Int = 17 , # hash table size, default 2^17
458- nr_thrds:: Int = 1 , # number of threads
459- max_nr_pairs:: Int = 0 , # number of pairs maximally chosen
460- # in symbolic preprocessing
461- la_option:: Int = 2 , # linear algebra option
462- info_level:: Int = 0 , # info level for print outs
463- precision:: Int = 32 # precision of the solution set
464- )
465-
466- isdefined (I, :inter_sols ) ||
467- _core_msolve (I,
468- initial_hts = initial_hts,
469- nr_thrds = nr_thrds,
470- max_nr_pairs = max_nr_pairs,
471- la_option = la_option,
472- info_level = info_level,
473- precision = precision)
474-
475- return I. inter_sols
425+ if interval
426+ return I. inter_sols
427+ else
428+ return I. real_sols
429+ end
476430end
0 commit comments