Skip to content

Commit

Permalink
Avoid bottlenecks in variable matching (#4178)
Browse files Browse the repository at this point in the history
  • Loading branch information
HechtiDerLachs authored Oct 7, 2024
1 parent c8a64e6 commit 9cda843
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Rings/MPolyMap/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/Rings/mpolyquo-localizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))

0 comments on commit 9cda843

Please sign in to comment.