Skip to content

Commit

Permalink
Remove superfluous if-clause and add some comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
HechtiDerLachs committed Sep 30, 2024
1 parent ab18726 commit eed444e
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions src/Rings/mpolyquo-localizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2762,33 +2762,28 @@ end
function _evaluate_general(
F::MPolyAnyMap{<:MPolyRing, CT}, u
) where {CT <: Union{<:MPolyQuoRing, <:MPolyLocRing, <:MPolyQuoLocRing}}
if domain(F) === codomain(F) && coefficient_map(F) === nothing
return evaluate(map_coefficients(coefficient_map(F), u,
parent = domain(F)), F.img_gens)
S = temp_ring(F)
if S !== nothing
if !isdefined(F, :variable_indices) || coefficient_ring(S) !== codomain(F)
return evaluate(map_coefficients(coefficient_map(F), u,
parent = S), F.img_gens)
else
tmp_poly = map_coefficients(coefficient_map(F), u, parent = S)
return _evaluate_with_build_ctx(tmp_poly, F.variable_indices, codomain(F))
end
else
S = temp_ring(F)
if S !== nothing
if !isdefined(F, :variable_indices) || coefficient_ring(S) !== codomain(F)
return evaluate(map_coefficients(coefficient_map(F), u,
parent = S), F.img_gens)
else
tmp_poly = map_coefficients(coefficient_map(F), u, parent = S)
return _evaluate_with_build_ctx(tmp_poly, F.variable_indices, codomain(F))
end
if !isdefined(F, :variable_indices)
return evaluate(map_coefficients(coefficient_map(F), u), F.img_gens)
else
if !isdefined(F, :variable_indices)
return evaluate(map_coefficients(coefficient_map(F), u), F.img_gens)
else
# For the case where we can recycle the method above, do so.
tmp_poly = map_coefficients(coefficient_map(F), u)
coefficient_ring(parent(tmp_poly)) === codomain(F) && return _evaluate_with_build_ctx(
tmp_poly,
F.variable_indices,
codomain(F)
)
# Otherwise default to the standard evaluation for the time being.
return evaluate(tmp_poly, F.img_gens)
end
# For the case where we can recycle the method above, do so.
tmp_poly = map_coefficients(coefficient_map(F), u)
coefficient_ring(parent(tmp_poly)) === codomain(F) && return _evaluate_with_build_ctx(
tmp_poly,
F.variable_indices,
codomain(F)
)
# Otherwise default to the standard evaluation for the time being.
return evaluate(tmp_poly, F.img_gens)
end
end
end
Expand All @@ -2814,6 +2809,9 @@ function _evaluate_with_build_ctx(
return Q(finish(ctx))
end

# The following methods are only safe, because they are called
# exclusively in a setup where variables map to variables
# and no denominators are introduced.
_coefficients(x::MPolyRingElem) = coefficients(x)
_coefficients(x::MPolyQuoRingElem) = coefficients(lift(x))
_coefficients(x::MPolyLocRingElem) = coefficients(numerator(x))
Expand Down

0 comments on commit eed444e

Please sign in to comment.