From 4c2807249d4be5ae91335ece11753713ac436a64 Mon Sep 17 00:00:00 2001 From: Martin Bies Date: Wed, 22 Dec 2021 17:16:01 +0100 Subject: [PATCH] Sophisticated show method for toric divisors --- docs/src/ToricVarieties/ToricDivisors.md | 1 + src/ToricVarieties/JToric.jl | 1 + .../ToricDivisors/attributes.jl | 19 +++- .../ToricDivisors/auxilliary.jl | 103 ++++++++++++++++++ .../ToricDivisors/constructors.jl | 18 +-- .../ToricDivisors/properties.jl | 20 ++-- test/ToricVarieties/runtests.jl | 1 + 7 files changed, 140 insertions(+), 23 deletions(-) create mode 100644 src/ToricVarieties/ToricDivisors/auxilliary.jl diff --git a/docs/src/ToricVarieties/ToricDivisors.md b/docs/src/ToricVarieties/ToricDivisors.md index f7112fbcedd0..575d3f7e9ee1 100644 --- a/docs/src/ToricVarieties/ToricDivisors.md +++ b/docs/src/ToricVarieties/ToricDivisors.md @@ -43,4 +43,5 @@ isvery_ample(td::ToricDivisor) ```@docs coefficients(td::ToricDivisor) polyhedron(td::ToricDivisor) +toricvariety(td::ToricDivisor) ``` diff --git a/src/ToricVarieties/JToric.jl b/src/ToricVarieties/JToric.jl index 94fdab0cab22..56f3b68c6dc3 100644 --- a/src/ToricVarieties/JToric.jl +++ b/src/ToricVarieties/JToric.jl @@ -7,6 +7,7 @@ include("NormalToricVarieties/methods.jl") include("CyclicQuotientSingularities/CyclicQuotientSingularities.jl") include("ToricDivisors/constructors.jl") +include("ToricDivisors/auxilliary.jl") include("ToricDivisors/properties.jl") include("ToricDivisors/attributes.jl") diff --git a/src/ToricVarieties/ToricDivisors/attributes.jl b/src/ToricVarieties/ToricDivisors/attributes.jl index 88432cc45b0c..7137a679dc57 100644 --- a/src/ToricVarieties/ToricDivisors/attributes.jl +++ b/src/ToricVarieties/ToricDivisors/attributes.jl @@ -16,7 +16,7 @@ julia> H = hirzebruch_surface(4) A normal toric variety corresponding to a polyhedral fan in ambient dimension 2 julia> td0 = ToricDivisor(H, [0,0,0,0]) -A torus invariant divisor on a normal toric variety +A torus invariant non-prime divisor on a normal toric variety julia> isfeasible(polyhedron(td0)) true @@ -25,13 +25,13 @@ julia> dim(polyhedron(td0)) 0 julia> td1 = ToricDivisor(H, [1,0,0,0]) -A torus invariant divisor on a normal toric variety +A torus invariant prime divisor on a normal toric variety julia> isfeasible(polyhedron(td1)) true julia> td2 = ToricDivisor(H, [-1,0,0,0]) -A torus invariant divisor on a normal toric variety +A torus invariant non-prime divisor on a normal toric variety julia> isfeasible(polyhedron(td2)) false @@ -57,7 +57,7 @@ julia> H = hirzebruch_surface(4) A normal toric variety corresponding to a polyhedral fan in ambient dimension 2 julia> D = ToricDivisor(H, [1,2,3,4]) -A torus invariant divisor on a normal toric variety +A torus invariant non-prime divisor on a normal toric variety julia> coefficients(D) 4-element Vector{Int64}: @@ -74,3 +74,14 @@ function coefficients(td::ToricDivisor) return get_attribute(td, :coefficients) end export coefficients + + +@doc Markdown.doc""" + toricvariety(td::ToricDivisor) + +Return the toric variety of a torus invariant Weil divisor. +""" +function toricvariety(td::ToricDivisor) + return get_attribute(td, :toricvariety) +end +export toricvariety diff --git a/src/ToricVarieties/ToricDivisors/auxilliary.jl b/src/ToricVarieties/ToricDivisors/auxilliary.jl new file mode 100644 index 000000000000..106465f5f14b --- /dev/null +++ b/src/ToricVarieties/ToricDivisors/auxilliary.jl @@ -0,0 +1,103 @@ +function output_string(td::ToricDivisor) + + # initiate the output string + out_string = "A torus invariant" + + # cartier? + if has_attribute(td, :iscartier) + if get_attribute(td, :iscartier) + out_string = out_string * " cartier,"; + else + if has_attribute(td, :isq_cartier) + if get_attribute(td, :isq_cartier) + out_string = out_string * " q-cartier,"; + else + out_string = out_string * " non-q-cartier,"; + end + else + out_string = out_string * " non-cartier,"; + end + end + end + + # principal? + if has_attribute(td, :isprincipal) + if get_attribute(td, :isprincipal) + out_string = out_string * " principal,"; + else + out_string = out_string * " non-principal,"; + end + end + + # basepoint free? + if has_attribute(td, :isbasepoint_free) + if get_attribute(td, :isbasepoint_free) + out_string = out_string * " basepoint-free,"; + else + out_string = out_string * " non-basepoint-free,"; + end + end + + # effective? + if has_attribute(td, :iseffective) + if get_attribute(td, :iseffective) + out_string = out_string * " effective,"; + else + out_string = out_string * " non-effective,"; + end + end + + # integral? + if has_attribute(td, :isintegral) + if get_attribute(td, :isintegral) + out_string = out_string * " integral,"; + else + out_string = out_string * " non-integral,"; + end + end + + # (very) ample? + if has_attribute(td, :isample) + if get_attribute(td, :isample) + out_string = out_string * " ample,"; + else + if has_attribute(td, :isvery_ample) + if get_attribute(td, :isvery_ample) + out_string = out_string * " very-ample,"; + else + out_string = out_string * " non-very-ample,"; + end + else + out_string = out_string * " non-ample,"; + end + end + end + + # nef? + if has_attribute(td, :isnef) + if get_attribute(td, :isnef) + out_string = out_string * " nef,"; + else + out_string = out_string * " non-nef,"; + end + end + + # prime divisor? + if has_attribute(td, :isprime_divisor) + if get_attribute(td, :isprime_divisor) + out_string = out_string * " prime"; + else + out_string = out_string * " non-prime"; + end + end + + # torusfactor? + if last(out_string) == ',' + out_string = chop(out_string) + end + out_string = out_string * " divisor on a" * chop(output_string(toricvariety(td)), head = 1, tail = 0) + + # return result + return out_string + +end diff --git a/src/ToricVarieties/ToricDivisors/constructors.jl b/src/ToricVarieties/ToricDivisors/constructors.jl index e82098573024..b6a0b5180d2c 100644 --- a/src/ToricVarieties/ToricDivisors/constructors.jl +++ b/src/ToricVarieties/ToricDivisors/constructors.jl @@ -23,8 +23,8 @@ Construct the torus invariant divisor on the normal toric variety `v` as linear # Examples ```jldoctest -julia> show(ToricDivisor(toric_projective_space(2), [1,1,2])) -A torus invariant divisor on a normal toric variety +julia> ToricDivisor(toric_projective_space(2), [1,1,2]) +A torus invariant non-prime divisor on a normal non-affine, smooth, projective, gorenstein, q-gorenstein, fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 ``` """ function ToricDivisor(v::AbstractNormalToricVariety, coeffs::Vector{Int}) @@ -40,6 +40,7 @@ function ToricDivisor(v::AbstractNormalToricVariety, coeffs::Vector{Int}) # set attributes set_attribute!(td, :coefficients, coeffs) + set_attribute!(td, :toricvariety, v) if sum(coeffs) != 1 set_attribute!(td, :isprime_divisor, false) else @@ -63,8 +64,8 @@ Construct the torus invariant divisor associated to a character of the normal to # Examples ```jldoctest -julia> show(DivisorOfCharacter(toric_projective_space(2), [1,2])) -A torus invariant divisor on a normal toric variety +julia> DivisorOfCharacter(toric_projective_space(2), [1,2]) +A torus invariant non-prime divisor on a normal non-affine, smooth, projective, gorenstein, q-gorenstein, fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 ``` """ function DivisorOfCharacter(v::AbstractNormalToricVariety, character::Vector{Int}) @@ -79,11 +80,10 @@ end export DivisorOfCharacter -############################################################################### -############################################################################### +###################### ### 4: Display -############################################################################### -############################################################################### +######################s + function Base.show(io::IO, td::ToricDivisor) - print(io, "A torus invariant divisor on a normal toric variety") + print(io, output_string(td)) end diff --git a/src/ToricVarieties/ToricDivisors/properties.jl b/src/ToricVarieties/ToricDivisors/properties.jl index 9ef8a0d3b9c4..de460919e401 100644 --- a/src/ToricVarieties/ToricDivisors/properties.jl +++ b/src/ToricVarieties/ToricDivisors/properties.jl @@ -9,7 +9,7 @@ julia> H = hirzebruch_surface(4) A normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> td = ToricDivisor(H, [1,0,0,0]) -A torus invariant divisor on a normal toric variety +A torus invariant prime divisor on a normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> iscartier(td) true @@ -34,7 +34,7 @@ julia> H = hirzebruch_surface(4) A normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> td = ToricDivisor(H, [1,0,0,0]) -A torus invariant divisor on a normal toric variety +A torus invariant prime divisor on a normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> isprincipal(td) false @@ -59,7 +59,7 @@ julia> H = hirzebruch_surface(4) A normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> td = ToricDivisor(H, [1,0,0,0]) -A torus invariant divisor on a normal toric variety +A torus invariant prime divisor on a normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> isbasepoint_free(td) true @@ -84,7 +84,7 @@ julia> H = hirzebruch_surface(4) A normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> td = ToricDivisor(H, [1,0,0,0]) -A torus invariant divisor on a normal toric variety +A torus invariant prime divisor on a normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> iseffective(td) true @@ -109,7 +109,7 @@ julia> H = hirzebruch_surface(4) A normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> td = ToricDivisor(H, [1,0,0,0]) -A torus invariant divisor on a normal toric variety +A torus invariant prime divisor on a normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> isintegral(td) true @@ -134,7 +134,7 @@ julia> H = hirzebruch_surface(4) A normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> td = ToricDivisor(H, [1,0,0,0]) -A torus invariant divisor on a normal toric variety +A torus invariant prime divisor on a normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> isample(td) false @@ -159,7 +159,7 @@ julia> H = hirzebruch_surface(4) A normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> td = ToricDivisor(H, [1,0,0,0]) -A torus invariant divisor on a normal toric variety +A torus invariant prime divisor on a normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> isvery_ample(td) false @@ -184,7 +184,7 @@ julia> H = hirzebruch_surface(4) A normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> td = ToricDivisor(H, [1,0,0,0]) -A torus invariant divisor on a normal toric variety +A torus invariant prime divisor on a normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> isnef(td) true @@ -209,7 +209,7 @@ julia> H = hirzebruch_surface(4) A normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> td = ToricDivisor(H, [1,0,0,0]) -A torus invariant divisor on a normal toric variety +A torus invariant prime divisor on a normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> isq_cartier(td) true @@ -235,7 +235,7 @@ julia> H = hirzebruch_surface(4) A normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> td = ToricDivisor(H, [1,0,0,0]) -A torus invariant divisor on a normal toric variety +A torus invariant prime divisor on a normal non-affine, smooth, projective, gorenstein, q-gorenstein, non-fano toric variety without torusfactor corresponding to a polyhedral fan in ambient dimension 2 julia> isprime_divisor(td) true diff --git a/test/ToricVarieties/runtests.jl b/test/ToricVarieties/runtests.jl index db9b6b0e2a4c..cbab7608611e 100644 --- a/test/ToricVarieties/runtests.jl +++ b/test/ToricVarieties/runtests.jl @@ -195,6 +195,7 @@ D=ToricDivisor(H5, [0,0,0,0]) D2 = DivisorOfCharacter(H5, [1,2]) @testset "Divisors" begin + @test dim(toricvariety(D)) == 2 @test isprime_divisor(D) == false @test iscartier(D) == true @test isprincipal(D) == true