Skip to content

Commit

Permalink
Sophisticated show method for toric divisors
Browse files Browse the repository at this point in the history
  • Loading branch information
HereAround committed Dec 22, 2021
1 parent b699ba8 commit 4c28072
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 23 deletions.
1 change: 1 addition & 0 deletions docs/src/ToricVarieties/ToricDivisors.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ isvery_ample(td::ToricDivisor)
```@docs
coefficients(td::ToricDivisor)
polyhedron(td::ToricDivisor)
toricvariety(td::ToricDivisor)
```
1 change: 1 addition & 0 deletions src/ToricVarieties/JToric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
19 changes: 15 additions & 4 deletions src/ToricVarieties/ToricDivisors/attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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}:
Expand All @@ -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
103 changes: 103 additions & 0 deletions src/ToricVarieties/ToricDivisors/auxilliary.jl
Original file line number Diff line number Diff line change
@@ -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
18 changes: 9 additions & 9 deletions src/ToricVarieties/ToricDivisors/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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
Expand All @@ -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})
Expand All @@ -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
20 changes: 10 additions & 10 deletions src/ToricVarieties/ToricDivisors/properties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/ToricVarieties/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4c28072

Please sign in to comment.