diff --git a/docs/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses.md b/docs/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses.md index 26a3e87818e5..5c05bbefb755 100644 --- a/docs/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses.md +++ b/docs/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses.md @@ -54,14 +54,14 @@ polynomial(ring::MPolyQuoRing, c::CohomologyClass) ## Methods ```@docs -integrate(c::CohomologyClass) +integrate(c::CohomologyClass; check::Bool = true) ``` ## Special attributes of toric varieties ```@docs -cohomology_ring(v::NormalToricVarietyType) +cohomology_ring(v::NormalToricVarietyType; check::Bool = true) volume_form(v::NormalToricVariety) intersection_form(v::NormalToricVariety) ``` diff --git a/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/methods.jl b/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/methods.jl index dfa115c6e579..23eca4350f2f 100644 --- a/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/methods.jl +++ b/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/methods.jl @@ -1,9 +1,14 @@ @doc raw""" - integrate(c::CohomologyClass) + integrate(c::CohomologyClass; check::Bool = true) Integrate the cohomolgy class `c` over the normal toric variety `toric_variety(c)`. +The theory underlying this method requires that the toric variety +in question is simplicial and complete. The check of completeness +may take a long time to complete. If desired, this can be switched +off by setting the optional argument `check` to the value `false`. + # Examples ```jldoctest julia> dP3 = del_pezzo_surface(NormalToricVariety, 3) @@ -88,10 +93,12 @@ julia> integrate(cohomology_class(anticanonical_divisor_class(X))^3) 62 ``` """ -function integrate(c::CohomologyClass) +function integrate(c::CohomologyClass; check::Bool = true) # can only integrate if the variety is simplicial, complete - @req is_simplicial(toric_variety(c)) && is_complete(toric_variety(c)) "Integration only supported over complete and simplicial toric varieties" - + if check + @req is_simplicial(toric_variety(c)) && is_complete(toric_variety(c)) "Integration only supported over complete and simplicial toric varieties" + end + # if the intersection form is known, we can use it if has_attribute(toric_variety(c), :_intersection_form_via_exponents) intersection_dict = _intersection_form_via_exponents(toric_variety(c)) diff --git a/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/special_attributes.jl b/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/special_attributes.jl index 0892d9a927a1..e5f2e1861f39 100644 --- a/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/special_attributes.jl +++ b/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/special_attributes.jl @@ -3,7 +3,7 @@ ######################## @doc raw""" - cohomology_ring(v::NormalToricVarietyType) + cohomology_ring(v::NormalToricVarietyType; check::Bool = true) Return the cohomology ring of the simplicial and complete toric variety `v`. @@ -15,12 +15,18 @@ julia> ngens(cohomology_ring(p2)) 3 ``` """ -@attr MPolyQuoRing function cohomology_ring(v::NormalToricVarietyType) +function cohomology_ring(v::NormalToricVarietyType; check::Bool = false) + if has_attribute(v, :cohomology_ring) + return get_attribute(v, :cohomology_ring) + end + if check @req is_simplicial(v) && is_complete(v) "The cohomology ring is only supported for simplicial and complete toric varieties" - 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) - return quo(R, linear_relations + stanley_reisner)[1] + 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) + set_attribute!(v, :cohomology_ring, quo(R, linear_relations + stanley_reisner)[1]) + return get_attribute(v, :cohomology_ring) end