Skip to content

Commit

Permalink
Curves: remove _assure_has_components
Browse files Browse the repository at this point in the history
Instead, just never access C.components directly, instead
use curve_components(C)
  • Loading branch information
fingolfin committed Feb 9, 2021
1 parent d261efe commit cd3c936
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
4 changes: 2 additions & 2 deletions examples/AffinePlaneCurve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ end
Return the reduced singular locus of `C` as a list whose first element is the affine plane curve consisting of the singular components of `C` (if any), and the second element is the list of the isolated singular points (which may be contained in the singular component). The singular component might not contain any point over the considered field.
"""
function curve_singular_locus(C::AffinePlaneCurve)
_assure_has_components(C)
comp = curve_components(C)
D = reduction(C)
Pts = Array{Point, 1}()
CC = Array{AffinePlaneCurve, 1}()
# The components with multiplicity > 1 are singular
f = []
for (h, c) in C.components
for (h, c) in comp
if c != 1
push!(f, h.eq)
end
Expand Down
27 changes: 10 additions & 17 deletions examples/PlaneCurve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,6 @@ function Oscar.jacobi_ideal(C::PlaneCurve)
return jacobi_ideal(C.eq)
end

################################################################################
# Helping function

function _assure_has_components(C::PlaneCurve)
if isempty(C.components)
T = typeof(C)
D = factor(C.eq)
C.components = Dict(T(x) => D.fac[x] for x in keys(D.fac))
end
end

################################################################################
# Components of the curve

Expand All @@ -241,7 +230,11 @@ end
Return a dictionary containing the irreducible components of `C` and their multiplicity.
"""
function curve_components(C::PlaneCurve)
_assure_has_components(C)
if isempty(C.components)
T = typeof(C)
D = factor(C.eq)
C.components = Dict(T(x) => D.fac[x] for x in keys(D.fac))
end
return C.components
end

Expand All @@ -255,8 +248,8 @@ end
Return `true` if `C` is irreducible, and `false` otherwise.
"""
function Oscar.isirreducible(C::PlaneCurve)
_assure_has_components(C)
return length(C.components) == 1 && all(isone, values(C.components))
comp = curve_components(C)
return length(comp) == 1 && all(isone, values(comp))
end

################################################################################
Expand Down Expand Up @@ -300,10 +293,10 @@ function reduction(C::AffinePlaneCurve)
end

function reduction(C::ProjPlaneCurve)
_assure_has_components(C)
F = prod(D -> D.eq, keys(C.components))
comp = curve_components(C)
F = prod(D -> D.eq, keys(comp))
rC = ProjPlaneCurve(F)
rC.components = Dict(ProjPlaneCurve(D.eq) => 1 for D in keys(C.components))
rC.components = Dict(ProjPlaneCurve(D.eq) => 1 for D in keys(comp))
return rC
end

Expand Down

0 comments on commit cd3c936

Please sign in to comment.