From 9cda843dfa5c3def261d3c592c9fc2434d961c52 Mon Sep 17 00:00:00 2001 From: Matthias Zach <85350711+HechtiDerLachs@users.noreply.github.com> Date: Mon, 7 Oct 2024 21:27:43 +0200 Subject: [PATCH] Avoid bottlenecks in variable matching (#4178) --- src/Rings/MPolyMap/Types.jl | 5 ++++- src/Rings/mpolyquo-localizations.jl | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Rings/MPolyMap/Types.jl b/src/Rings/MPolyMap/Types.jl index 9f22448a96e..6c56fd1cf62 100644 --- a/src/Rings/MPolyMap/Types.jl +++ b/src/Rings/MPolyMap/Types.jl @@ -35,12 +35,15 @@ const _DomainTypes = Union{MPolyRing, MPolyQuoRing} # can safely be disabled. if check_for_mapping_of_vars && all(_is_gen, img_gens) && _allunique(img_gens) gens_codomain = gens(codomain) - result.variable_indices = [findfirst(==(x), gens_codomain) for x in img_gens] + result.variable_indices = [findfirst(_cmp_reps(x), gens_codomain) for x in img_gens] end return result end end +# This can be overwritten in order to avoid making the above check a bottleneck. +_cmp_reps(a) = ==(a) + function MPolyAnyMap(d::D, c::C, cm::U, ig::Vector{V}) where {D, C, U, V} return MPolyAnyMap{D, C, U, V}(d, c, cm, ig) end diff --git a/src/Rings/mpolyquo-localizations.jl b/src/Rings/mpolyquo-localizations.jl index f9357af03df..e0e3ecf557d 100644 --- a/src/Rings/mpolyquo-localizations.jl +++ b/src/Rings/mpolyquo-localizations.jl @@ -2804,3 +2804,7 @@ _exponents(x::MPolyQuoRingElem) = AbstractAlgebra.exponent_vectors(lift(x)) _exponents(x::MPolyLocRingElem) = AbstractAlgebra.exponent_vectors(numerator(x)) _exponents(x::MPolyQuoLocRingElem) = AbstractAlgebra.exponent_vectors(lifted_numerator(x)) +# overwriting the comparison method to avoid computing saturations and groebner bases. +_cmp_reps(a::MPolyLocRingElem) = y->(fraction(y) == fraction(a)) +_cmp_reps(a::MPolyQuoLocRingElem) = y->(fraction(y) == fraction(a)) +