Skip to content

Commit

Permalink
Experiment to harvest yet more speed
Browse files Browse the repository at this point in the history
  • Loading branch information
HereAround committed Jul 31, 2024
1 parent cd5dbaf commit 5cef3ba
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 21 deletions.
46 changes: 25 additions & 21 deletions experimental/FTheoryTools/src/AbstractFTheoryModels/attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ function chern_class_c1(m::AbstractFTheoryModel; check::Bool = true)
end

# Trigger potential short-cut computation of cohomology ring
cohomology_ring(ambient_space(m); check)
cohomology_ring(ambient_space(m); check = check)

# Compute the cohomology class corresponding to the hypersurface equation
cy = cohomology_class(toric_divisor_class(ambient_space(m), degree(hypersurface_equation(m))))
Expand Down Expand Up @@ -1183,8 +1183,11 @@ function chern_class_c2(m::AbstractFTheoryModel; check::Bool = true)
return get_attribute(m, :chern_class_c2)
end

# Trigger potential short-cut computation of cohomology ring
cohomology_ring(ambient_space(m); check)
# Compute elements of the cohomology ring corresponding to the torus invariant prime divisors
c_ds = [g.f for g in gens(cohomology_ring(ambient_space(m); check = false))]
R = parent(c_ds[1])
projection_map = hom(R, cohomology_ring(ambient_space(m); check = false), gens(R))
len_c_ds = length(c_ds)

# Compute the cohomology class corresponding to the hypersurface equation
cy = cohomology_class(toric_divisor_class(ambient_space(m), degree(hypersurface_equation(m))))
Expand All @@ -1193,17 +1196,15 @@ function chern_class_c2(m::AbstractFTheoryModel; check::Bool = true)
mnf = Oscar._minimal_nonfaces(ambient_space(m))
indices = [findall(x -> x == 1, Vector{Int}(mnf[i, :])) for i in 1:Polymake.nrows(mnf)]

# Compute c4 of the toric ambient space
c_ds = [polynomial(cohomology_class(d)) for d in torusinvariant_prime_divisors(ambient_space(m))]
len_c_ds = length(c_ds)
c2_t_ambient = zero(cohomology_ring(ambient_space(m)))
# Compute c2 of the toric ambient space
c2_t_ambient = zero(R)
for i in 1:len_c_ds - 1
for j in i+1:len_c_ds
[i,j] in indices && continue
c2_t_ambient = c2_t_ambient + c_ds[i] * c_ds[j]
end
end
c2_t_ambient = cohomology_class(ambient_space(m), c2_t_ambient)
c2_t_ambient = cohomology_class(ambient_space(m), projection_map(c2_t_ambient))

# Compute and set h
h = c2_t_ambient - cy * chern_class_c1(m; check = check)
Expand Down Expand Up @@ -1249,8 +1250,11 @@ function chern_class_c3(m::AbstractFTheoryModel; check::Bool = true)
return get_attribute(m, :chern_class_c3)

Check warning on line 1250 in experimental/FTheoryTools/src/AbstractFTheoryModels/attributes.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/AbstractFTheoryModels/attributes.jl#L1250

Added line #L1250 was not covered by tests
end

# Trigger potential short-cut computation of cohomology ring
cohomology_ring(ambient_space(m); check)
# Compute elements of the cohomology ring corresponding to the torus invariant prime divisors
c_ds = [g.f for g in gens(cohomology_ring(ambient_space(m); check = false))]
R = parent(c_ds[1])
projection_map = hom(R, cohomology_ring(ambient_space(m); check = false), gens(R))
len_c_ds = length(c_ds)

# Compute the cohomology class corresponding to the hypersurface equation
cy = cohomology_class(toric_divisor_class(ambient_space(m), degree(hypersurface_equation(m))))
Expand All @@ -1259,10 +1263,8 @@ function chern_class_c3(m::AbstractFTheoryModel; check::Bool = true)
mnf = Oscar._minimal_nonfaces(ambient_space(m))
indices = [findall(x -> x == 1, Vector{Int}(mnf[i, :])) for i in 1:Polymake.nrows(mnf)]

# Compute c4 of the toric ambient space
c_ds = [polynomial(cohomology_class(d)) for d in torusinvariant_prime_divisors(ambient_space(m))]
len_c_ds = length(c_ds)
c3_t_ambient = zero(cohomology_ring(ambient_space(m)))
# Compute c3 of the toric ambient space
c3_t_ambient = zero(R)
for i in 1:len_c_ds - 2
for j in i+1:len_c_ds - 1
[i,j] in indices && continue
Expand All @@ -1273,7 +1275,7 @@ function chern_class_c3(m::AbstractFTheoryModel; check::Bool = true)
end
end
end
c3_t_ambient = cohomology_class(ambient_space(m), c3_t_ambient)
c3_t_ambient = cohomology_class(ambient_space(m), projection_map(c3_t_ambient))

# Compute and set h
h = c3_t_ambient - cy * chern_class_c2(m; check = check)
Expand Down Expand Up @@ -1319,8 +1321,12 @@ function chern_class_c4(m::AbstractFTheoryModel; check::Bool = true)
return get_attribute(m, :chern_class_c4)

Check warning on line 1321 in experimental/FTheoryTools/src/AbstractFTheoryModels/attributes.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/AbstractFTheoryModels/attributes.jl#L1321

Added line #L1321 was not covered by tests
end

# Trigger potential short-cut computation of cohomology ring
cohomology_ring(ambient_space(m); check)
# Compute elements of the cohomology ring corresponding to the torus invariant prime divisors
q = Oscar._cohomology_ring_with_quotient_map(ambient_space(m); check = false)
c_ds = [g.f for g in gens(q[1])]
R = parent(c_ds[1])
projection_map = q[2]
len_c_ds = length(c_ds)

# Compute the cohomology class corresponding to the hypersurface equation
cy = cohomology_class(toric_divisor_class(ambient_space(m), degree(hypersurface_equation(m))))
Expand All @@ -1330,9 +1336,7 @@ function chern_class_c4(m::AbstractFTheoryModel; check::Bool = true)
indices = [findall(x -> x == 1, Vector{Int}(mnf[i, :])) for i in 1:Polymake.nrows(mnf)]

# Compute c4 of the toric ambient space
c_ds = [polynomial(cohomology_class(d)) for d in torusinvariant_prime_divisors(ambient_space(m))]
len_c_ds = length(c_ds)
c4_t_ambient = zero(cohomology_ring(ambient_space(m)))
c4_t_ambient = zero(R)
for i in 1:len_c_ds - 3
for j in i+1:len_c_ds - 2
[i,j] in indices && continue
Expand All @@ -1347,7 +1351,7 @@ function chern_class_c4(m::AbstractFTheoryModel; check::Bool = true)
end
end
end
c4_t_ambient = cohomology_class(ambient_space(m), c4_t_ambient)
c4_t_ambient = cohomology_class(ambient_space(m), projection_map(c4_t_ambient))

# Compute and set h
h = c4_t_ambient - cy * chern_class_c3(m; check = check)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ function cohomology_ring(v::NormalToricVarietyType; check::Bool = true)
end


function _cohomology_ring_with_quotient_map(v::NormalToricVarietyType; check::Bool = true)
if check
@req is_simplicial(v) && is_complete(v) "The cohomology ring is only supported for simplicial and complete toric varieties"

Check warning on line 35 in src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/special_attributes.jl

View check run for this annotation

Codecov / codecov/patch

src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/special_attributes.jl#L35

Added line #L35 was not covered by tests
end
R, _ = graded_polynomial_ring(coefficient_ring(v), coordinate_names(v), cached = false)
linear_relations = ideal_of_linear_relations(R, v)
stanley_reisner = stanley_reisner_ideal(R, v)
q = quo(R, linear_relations + stanley_reisner)
set_attribute!(v, :cohomology_ring, q[1])
return q
end


@doc raw"""
volume_form(v::NormalToricVariety)
Expand Down

0 comments on commit 5cef3ba

Please sign in to comment.