Skip to content

Commit

Permalink
[FTheoryTools] Reduce allocs in singular_loci computation
Browse files Browse the repository at this point in the history
  • Loading branch information
HereAround committed Jan 11, 2025
1 parent 75a0598 commit ea75840
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 48 deletions.
34 changes: 12 additions & 22 deletions experimental/FTheoryTools/src/WeierstrassModels/attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,30 +244,20 @@ julia> length(singular_loci(w))
"""
@attr Vector{<:Tuple{<:MPolyIdeal{<:MPolyRingElem}, Tuple{Int64, Int64, Int64}, String}} function singular_loci(w::WeierstrassModel)
@req (base_space(w) isa NormalToricVariety || base_space(w) isa FamilyOfSpaces) "Singular loci of Weierstrass model is currently only supported for toric varieties and families of spaces as base space"

B = irrelevant_ideal(base_space(w))

d_primes = primary_decomposition(ideal([discriminant(w)]))
nontrivial_d_primes = Tuple{<:MPolyIdeal{<:MPolyRingElem}, <:MPolyIdeal{<:MPolyRingElem}}[]
for k in 1:length(d_primes)
if _is_nontrivial(d_primes[k][2], B)
push!(nontrivial_d_primes, d_primes[k])
end
end

f_primes = primary_decomposition(ideal([weierstrass_section_f(w)]))
g_primes = primary_decomposition(ideal([weierstrass_section_g(w)]))

kodaira_types = Tuple{<:MPolyIdeal{<:MPolyRingElem}, Tuple{Int64, Int64, Int64}, String}[]
for d_prime in nontrivial_d_primes
f_index = findfirst(fp -> fp[2] == d_prime[2], f_primes)
g_index = findfirst(gp -> gp[2] == d_prime[2], g_primes)
f_order = !isnothing(f_index) ? saturation_with_index(f_primes[f_index][1], d_prime[2])[2] : 0
g_order = !isnothing(g_index) ? saturation_with_index(g_primes[g_index][1], d_prime[2])[2] : 0
d_order = saturation_with_index(d_prime[1], d_prime[2])[2]
d_primes = factor(discriminant(w))
nontrivial_d_primes = [k for k in d_primes if _is_nontrivial(ideal([k[1]]), B)]
f_primes = factor(weierstrass_section_f(w))
g_primes = factor(weierstrass_section_g(w))
f_prime_dict = Dict(fp[1] => fp[2] for fp in f_primes)
g_prime_dict = Dict(gp[1] => gp[2] for gp in g_primes)
kodaira_types = Vector{Tuple{<:MPolyIdeal{<:MPolyRingElem}, Tuple{Int64, Int64, Int64}, String}}(undef, length(nontrivial_d_primes))
for (i, d_prime) in enumerate(nontrivial_d_primes)
f_order = get(f_prime_dict, d_prime[1], 0)
g_order = get(g_prime_dict, d_prime[1], 0)
d_order = d_prime[2]
ords = (f_order, g_order, d_order)
push!(kodaira_types, (d_prime[2], ords, _kodaira_type(d_prime[2], ords, w)))
kodaira_types[i] = (ideal([d_prime[1]]), ords, _kodaira_type(ideal([d_prime[1]]), ords, w))
end

return kodaira_types
end
46 changes: 20 additions & 26 deletions experimental/FTheoryTools/test/literature_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# 1: Literature Tate model over concrete base
#############################################################

#=
B3 = projective_space(NormalToricVariety, 3)
w = torusinvariant_prime_divisors(B3)[1]
t1 = literature_model(arxiv_id = "1109.3454", equation = "3.1", base_space = B3, model_sections = Dict("w" => w), completeness_check = false)
Expand Down Expand Up @@ -483,10 +484,11 @@ end
#############################################################################
# 9: Test models from F-theory on all toric hypersurfaces over concrete base
#############################################################################

=#
B3 = projective_space(NormalToricVariety, 3)
Kbar = anticanonical_divisor(B3)
foah1_B3 = literature_model(arxiv_id = "1408.4808", equation = "3.4", type = "hypersurface", base_space = B3, defining_classes = Dict("s7" => Kbar, "s9" => Kbar), completeness_check = false)
#=
foah2_B3 = literature_model(arxiv_id = "1408.4808", equation = "3.12", type = "hypersurface", base_space = B3, defining_classes = Dict("b7" => Kbar, "b9" => Kbar), completeness_check = false)
foah3_B3 = literature_model(arxiv_id = "1408.4808", equation = "3.54", type = "hypersurface", base_space = B3, defining_classes = Dict("s7" => Kbar, "s9" => Kbar), completeness_check = false)
foah4_B3 = literature_model(arxiv_id = "1408.4808", equation = "3.17", type = "hypersurface", base_space = B3, defining_classes = Dict("s7" => Kbar, "s9" => Kbar), completeness_check = false)
Expand Down Expand Up @@ -676,7 +678,7 @@ foah16_weier = weierstrass_model(foah16)
@test model_description(foah15_weier) == "F-theory weierstrass model dual to hypersurface model with fiber ambient space F_15"
@test model_description(foah16_weier) == "F-theory weierstrass model dual to hypersurface model with fiber ambient space F_16"
end

=#


########################################################################################################
Expand Down Expand Up @@ -799,28 +801,20 @@ foah16_B3_weier = literature_model(arxiv_id = "1408.4808", equation = "3.203", t
@test length(singular_loci(foah14_B3_weier)) == 4
@test length(singular_loci(foah15_B3_weier)) == 5
@test length(singular_loci(foah16_B3_weier)) == 4
@test singular_loci(foah4_B3_weier)[2][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah6_B3_weier)[2][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah8_B3_weier)[2][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah8_B3_weier)[3][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah9_B3_weier)[2][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah10_B3_weier)[2][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah10_B3_weier)[3][2:3] == ((0, 0, 3), "Split I_3")
@test singular_loci(foah11_B3_weier)[2][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah11_B3_weier)[3][2:3] == ((0, 0, 3), "Split I_3")
@test singular_loci(foah12_B3_weier)[2][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah12_B3_weier)[3][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah13_B3_weier)[2][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah13_B3_weier)[3][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah13_B3_weier)[4][2:3] == ((0, 0, 4), "Split I_4")
@test singular_loci(foah14_B3_weier)[2][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah14_B3_weier)[3][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah14_B3_weier)[4][2:3] == ((0, 0, 3), "Split I_3")
@test singular_loci(foah15_B3_weier)[2][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah15_B3_weier)[3][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah15_B3_weier)[4][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah15_B3_weier)[5][2:3] == ((0, 0, 2), "Non-split I_2")
@test singular_loci(foah16_B3_weier)[2][2:3] == ((0, 0, 3), "Split I_3")
@test singular_loci(foah16_B3_weier)[3][2:3] == ((0, 0, 3), "Split I_3")
@test singular_loci(foah16_B3_weier)[4][2:3] == ((0, 0, 3), "Split I_3")
@test sort([k[2:3] for k in singular_loci(foah1_B3_weier)]) == [((0, 0, 1), "I_1")]
@test sort([k[2:3] for k in singular_loci(foah2_B3_weier)]) == [((0, 0, 1), "I_1")]
@test sort([k[2:3] for k in singular_loci(foah3_B3_weier)]) == [((0, 0, 1), "I_1")]
@test sort([k[2:3] for k in singular_loci(foah4_B3_weier)]) == [((0, 0, 1), "I_1"), ((0, 0, 2), "Non-split I_2")]
@test sort([k[2:3] for k in singular_loci(foah5_B3_weier)]) == [((0, 0, 1), "I_1")]
@test sort([k[2:3] for k in singular_loci(foah6_B3_weier)]) == [((0, 0, 1), "I_1"), ((0, 0, 2), "Non-split I_2")]
@test sort([k[2:3] for k in singular_loci(foah7_B3_weier)]) == [((0, 0, 1), "I_1")]
@test sort([k[2:3] for k in singular_loci(foah8_B3_weier)]) == [((0, 0, 1), "I_1"), ((0, 0, 2), "Non-split I_2"), ((0, 0, 2), "Non-split I_2")]
@test sort([k[2:3] for k in singular_loci(foah9_B3_weier)]) == [((0, 0, 1), "I_1"), ((0, 0, 2), "Non-split I_2")]
@test sort([k[2:3] for k in singular_loci(foah10_B3_weier)]) == [((0, 0, 1), "I_1"), ((0, 0, 2), "Non-split I_2"), ((0, 0, 3), "Split I_3")]
@test sort([k[2:3] for k in singular_loci(foah11_B3_weier)]) == [((0, 0, 1), "I_1"), ((0, 0, 2), "Non-split I_2"), ((0, 0, 3), "Split I_3")]
@test sort([k[2:3] for k in singular_loci(foah12_B3_weier)]) == [((0, 0, 1), "I_1"), ((0, 0, 2), "Non-split I_2"), ((0, 0, 2), "Non-split I_2")]
@test sort([k[2:3] for k in singular_loci(foah13_B3_weier)]) == [((0, 0, 1), "I_1"), ((0, 0, 2), "Non-split I_2"), ((0, 0, 2), "Non-split I_2"), ((0, 0, 4), "Split I_4")]
@test sort([k[2:3] for k in singular_loci(foah14_B3_weier)]) == [((0, 0, 1), "I_1"), ((0, 0, 2), "Non-split I_2"), ((0, 0, 2), "Non-split I_2"), ((0, 0, 3), "Split I_3")]
@test sort([k[2:3] for k in singular_loci(foah15_B3_weier)]) == [((0, 0, 1), "I_1"), ((0, 0, 2), "Non-split I_2"), ((0, 0, 2), "Non-split I_2"), ((0, 0, 2), "Non-split I_2"), ((0, 0, 2), "Non-split I_2")]
@test sort([k[2:3] for k in singular_loci(foah16_B3_weier)]) == [((0, 0, 1), "I_1"), ((0, 0, 3), "Split I_3"), ((0, 0, 3), "Split I_3"), ((0, 0, 3), "Split I_3")]
end

0 comments on commit ea75840

Please sign in to comment.