diff --git a/benchmark/CI-scripts/run_benchmarks.jl b/benchmark/CI-scripts/run_benchmarks.jl index b92eb769..fac879eb 100644 --- a/benchmark/CI-scripts/run_benchmarks.jl +++ b/benchmark/CI-scripts/run_benchmarks.jl @@ -64,8 +64,6 @@ function nemo_make_prime_finite_field(p) end function compute_gb(system, trials=7; kws...) - kws = Dict{Symbol, Any}(kws) - !haskey(kws, :threaded) && (kws[:threaded] = :no) times = [] for _ in 1:trials GC.gc() diff --git a/src/Groebner.jl b/src/Groebner.jl index 91d91d24..d09e2fcd 100644 --- a/src/Groebner.jl +++ b/src/Groebner.jl @@ -167,7 +167,7 @@ include("groebner/homogenization.jl") include("interface.jl") using PrecompileTools -# include("precompile.jl") +include("precompile.jl") ### # Exports diff --git a/src/f4/matrix.jl b/src/f4/matrix.jl index 78b20999..ba61ebdb 100644 --- a/src/f4/matrix.jl +++ b/src/f4/matrix.jl @@ -185,8 +185,6 @@ function matrix_string_repr(matrix::MacaulayMatrix{T}) where {T} C: $(m_C) x $(n_C) with $(nnz_C) nnz ($(percent(nnz_C / (m_C * n_C)))%) D: $(m_D) x $(n_D) with $(nnz_D) nnz ($(percent(nnz_D / (m_D * n_D)))%) - RREF flag: $(matrix.upper_part_is_rref) - Sparsity pattern: $(canvas) diff --git a/src/groebner/groebner.jl b/src/groebner/groebner.jl index 29d7b125..59090c43 100644 --- a/src/groebner/groebner.jl +++ b/src/groebner/groebner.jl @@ -65,8 +65,7 @@ function __groebner1( params::AlgorithmParameters ) where {I <: Integer, C <: Coeff} @invariant ir_is_valid(ring, monoms, coeffs) - _, ring2, monoms2, coeffs2 = - ir_convert_ir_to_internal(ring, monoms, coeffs, params, params.representation) + _, ring2, monoms2, coeffs2 = ir_convert_ir_to_internal(ring, monoms, coeffs, params) gb_monoms2, gb_coeffs2 = groebner2(ring2, monoms2, coeffs2, params) gb_monoms, gb_coeffs = ir_convert_internal_to_ir(ring2, gb_monoms2, gb_coeffs2, params) gb_monoms, gb_coeffs diff --git a/src/groebner/groebner_with_change_matrix.jl b/src/groebner/groebner_with_change_matrix.jl index 39bf0f2d..cd03b043 100644 --- a/src/groebner/groebner_with_change_matrix.jl +++ b/src/groebner/groebner_with_change_matrix.jl @@ -42,8 +42,7 @@ end function __groebner_with_change_matrix1(ring, monoms, coeffs, params) @invariant ir_is_valid(ring, monoms, coeffs) - _, ring2, monoms2, coeffs2 = - ir_convert_ir_to_internal(ring, monoms, coeffs, params, params.representation) + _, ring2, monoms2, coeffs2 = ir_convert_ir_to_internal(ring, monoms, coeffs, params) gb_monoms2, gb_coeffs2, matrix_monoms2, matrix_coeffs2 = groebner_with_change_matrix2(ring2, monoms2, coeffs2, params) gb_monoms, gb_coeffs = ir_convert_internal_to_ir(ring2, gb_monoms2, gb_coeffs2, params) diff --git a/src/groebner/isgroebner.jl b/src/groebner/isgroebner.jl index 93a64f17..c3643484 100644 --- a/src/groebner/isgroebner.jl +++ b/src/groebner/isgroebner.jl @@ -33,8 +33,7 @@ end function __isgroebner1(ring, monoms, coeffs, params) @invariant ir_is_valid(ring, monoms, coeffs) - _, ring2, monoms2, coeffs2 = - ir_convert_ir_to_internal(ring, monoms, coeffs, params, params.representation) + _, ring2, monoms2, coeffs2 = ir_convert_ir_to_internal(ring, monoms, coeffs, params) isgroebner2(ring2, monoms2, coeffs2, params) end diff --git a/src/groebner/learn_apply.jl b/src/groebner/learn_apply.jl index cd87ea0f..c10f584c 100644 --- a/src/groebner/learn_apply.jl +++ b/src/groebner/learn_apply.jl @@ -57,7 +57,7 @@ function __groebner_learn1( ) where {I <: Integer, C <: Coeff} @invariant ir_is_valid(ring, monoms, coeffs) term_sorting_permutations, ring2, monoms2, coeffs2 = - ir_convert_ir_to_internal(ring, monoms, coeffs, params, params.representation) + ir_convert_ir_to_internal(ring, monoms, coeffs, params) trace, gb_monoms2, gb_coeffs2 = groebner_learn2(ring2, monoms2, coeffs2, params) gb_monoms, gb_coeffs = ir_convert_internal_to_ir(ring2, gb_monoms2, gb_coeffs2, params) diff --git a/src/groebner/normalform.jl b/src/groebner/normalform.jl index c4c9241b..3644fd40 100644 --- a/src/groebner/normalform.jl +++ b/src/groebner/normalform.jl @@ -88,15 +88,9 @@ function __normalform1( @invariant ir_is_valid(ring, monoms, coeffs) @invariant ir_is_valid(ring_tbr, monoms_tbr, coeffs_tbr) - _, ring2, monoms2, coeffs2 = - ir_convert_ir_to_internal(ring, monoms, coeffs, params, params.representation) - _, ring_tbr2, monoms_tbr2, coeffs_tbr2 = ir_convert_ir_to_internal( - ring_tbr, - monoms_tbr, - coeffs_tbr, - params, - params.representation - ) + _, ring2, monoms2, coeffs2 = ir_convert_ir_to_internal(ring, monoms, coeffs, params) + _, ring_tbr2, monoms_tbr2, coeffs_tbr2 = + ir_convert_ir_to_internal(ring_tbr, monoms_tbr, coeffs_tbr, params) monoms_reduced2, coeffs_reduced2 = normalform2(ring2, monoms2, coeffs2, ring_tbr2, monoms_tbr2, coeffs_tbr2, params) monoms_reduced, coeffs_reduced = diff --git a/src/input_output/intermediate.jl b/src/input_output/intermediate.jl index 86c0c6bd..69b00c2f 100644 --- a/src/input_output/intermediate.jl +++ b/src/input_output/intermediate.jl @@ -31,16 +31,16 @@ end Base.:(==)(r1::PolyRing, r2::PolyRing) = r1.nvars == r2.nvars && r1.ord == r2.ord && r1.ch == r2.ch -ir_basic_is_valid(batch) = throw(DomainError("Invalid IR, unknown types.")) -ir_basic_is_valid(ring, monoms, coeffs) = throw(DomainError("Invalid IR, unknown types.")) +ir_is_valid_basic(batch) = throw(DomainError("Invalid IR, unknown types.")) +ir_is_valid_basic(ring, monoms, coeffs) = throw(DomainError("Invalid IR, unknown types.")) -function ir_basic_is_valid(batch::NTuple{N, T}) where {N, T} +function ir_is_valid_basic(batch::NTuple{N, T}) where {N, T} for el in batch - ir_basic_is_valid(el...) + ir_is_valid_basic(el...) end end -function ir_basic_is_valid( +function ir_is_valid_basic( ring::PolyRing, monoms::Vector{Vector{Vector{T}}}, coeffs::Vector{Vector{C}} @@ -66,7 +66,7 @@ function ir_is_valid( monoms::Vector{Vector{Vector{T}}}, coeffs::Vector{Vector{C}} ) where {T <: Integer, C <: Number} - ir_basic_is_valid(ring, monoms, coeffs) + ir_is_valid_basic(ring, monoms, coeffs) for i in 1:length(monoms) !(length(monoms[i]) == length(coeffs[i])) && throw(DomainError("Invalid IR.")) for j in 1:length(monoms[i]) @@ -86,7 +86,7 @@ function ir_ensure_assumptions( monoms::Vector{Vector{Vector{M}}}, coeffs::Vector{Vector{C}} ) where {M <: Integer, C <: Coeff} - ir_basic_is_valid(ring, monoms, coeffs) + ir_is_valid_basic(ring, monoms, coeffs) # Copy input new_monoms, new_coeffs = empty(monoms), empty(coeffs) for i in 1:length(monoms) @@ -203,7 +203,13 @@ end ### # Converting to internal representation -function ir_convert_ir_to_internal(ring, monoms, coeffs, params, repr) +function ir_convert_ir_to_internal( + ring::PolyRing, + monoms::Vector{Vector{M}}, + coeffs::Vector{Vector{C}}, + params +) where {M <: Monom, C <: Coeff} + repr = params.representation monoms2 = Vector{Vector{repr.monomtype}}(undef, length(monoms)) coeffs2 = Vector{Vector{repr.coefftype}}(undef, length(monoms)) @inbounds for i in 1:length(monoms) @@ -219,7 +225,12 @@ function ir_convert_ir_to_internal(ring, monoms, coeffs, params, repr) term_sorting_permutations, ring2, monoms2, coeffs2 end -function ir_convert_internal_to_ir(ring, monoms, coeffs, params) +function ir_convert_internal_to_ir( + ring::PolyRing, + monoms::Vector{Vector{M}}, + coeffs::Vector{Vector{C}}, + params +) where {M <: Monom, C <: Coeff} monoms2 = Vector{Vector{Vector{IRexponent}}}(undef, length(monoms)) coeffs2 = coeffs if eltype(eltype(coeffs)) <: AbstractFloat @@ -237,7 +248,12 @@ end # Checks that the monomial ordering is consistent. # Sorts the polynomials terms w.r.t. the target ordering. -function ir_set_monomial_ordering!(ring, monoms, coeffs, params) +function ir_set_monomial_ordering!( + ring::PolyRing, + monoms::Vector{Vector{M}}, + coeffs::Vector{Vector{C}}, + params +) where {M <: Monom, C <: Coeff} ordering_check_consistency(ring.nvars, params.target_ord) if ring.ord == params.target_ord # No reordering of terms needed diff --git a/src/interface.jl b/src/interface.jl index afb73cac..18dd58ae 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -179,7 +179,7 @@ function groebner( logging_setup(keywords) - ir_basic_is_valid(ring, monoms, coeffs) + ir_is_valid_basic(ring, monoms, coeffs) result = groebner1(ring, monoms, coeffs, keywords) result @@ -378,7 +378,7 @@ function groebner_learn( logging_setup(keywords) - ir_basic_is_valid(ring, monoms, coeffs) + ir_is_valid_basic(ring, monoms, coeffs) result = groebner_learn1(ring, monoms, coeffs, keywords) result @@ -462,7 +462,7 @@ function groebner_apply!( logging_setup(keywords) - ir_basic_is_valid(ring, monoms, coeffs) + ir_is_valid_basic(ring, monoms, coeffs) result = groebner_apply1!(trace, ring, monoms, coeffs, keywords) result @@ -477,7 +477,7 @@ function groebner_apply!(trace::WrappedTrace, batch::NTuple{N, T}; options...) w logging_setup(keywords) - ir_basic_is_valid(batch) + ir_is_valid_basic(batch) result = groebner_apply_batch1!(trace, batch, keywords) result @@ -568,7 +568,7 @@ function isgroebner( logging_setup(keywords) - ir_basic_is_valid(ring, monoms, coeffs) + ir_is_valid_basic(ring, monoms, coeffs) result = isgroebner1(ring, monoms, coeffs, keywords) result @@ -662,8 +662,8 @@ function normalform( logging_setup(keywords) - ir_basic_is_valid(ring, monoms, coeffs) - ir_basic_is_valid(ring_to_be_reduced, monoms_to_be_reduced, coeffs_to_be_reduced) + ir_is_valid_basic(ring, monoms, coeffs) + ir_is_valid_basic(ring_to_be_reduced, monoms_to_be_reduced, coeffs_to_be_reduced) result = normalform1( ring, monoms,