Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New method to convert toric divisors into Weil divisors #3076

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions experimental/Schemes/NormalToricVarieties/attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,56 @@ function _torusinvariant_weil_divisors(X::NormalToricVariety; check::Bool=false)
set_attribute!(X, :_torusinvariant_weil_divisors=>result)
return result
end

function _weil_divisor_via_polymake(X::NormalToricVariety, c::Vector{ZZRingElem}; check::Bool=false)
ray_list = rays(polyhedral_fan(X))
ideal_dict = IdDict{AbsSpec, Ideal}()
for U in affine_charts(X)

# Populate a dict for the mapping of the local rays of the cone of U
# to the rays of the fan
sigma = cone(U)
sigma_dual = weight_cone(U)
r_sigma = rays(sigma)
div_dict = Dict{RayVector, RayVector}()
index_dict = Vector{Int}()
for (i, r) in enumerate(r_sigma)
k = findfirst(s->s==r, ray_list)
k === nothing && error("ray not found")
div_dict[r] = ray_list[k]
push!(index_dict, k)
end
@show index_dict
if isempty(index_dict)
ideal_dict[U] = ideal(OO(U), one(OO(U)))
continue
end
loc_c = c[index_dict]
loc_div = toric_divisor(U, loc_c)
# A is a matrix and its rows are the coordinates of the lattice
# points generating the local ideal.
A = pm_object(loc_div).MODULE_GENERATORS
@show A
g = [A[i, :] for i in 1:nrows(A)]
# We need to convert them to their representations in the
# hilbert basis for this chart.
hb = hilbert_basis(U)::ZZMatrix
for i in 1:nrows(A)
@show i
# Manually convert the rows of A to a ZZMatrix so that solve_mixed will take it
# Why don't we do A all at once? Because `solve_mixed` won't accept real matrices
# as second argument. Duh.
b = zero_matrix(ZZ, ncols(A), 1)
for j in 1:ncols(A)
b[j, 1] = ZZ(A[i, j])
end
@show transpose(hb)
@show b
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the part of the code I was talking about. The example I was running was:

IP = projective_space(NormalToricVariety, 2)
Oscar._weil_divisor_via_polymake(IP, elem_type(ZZ)[1, 0, 0])

c_in_hb = solve_mixed(ZZMatrix, transpose(hb), b, identity_matrix(ZZ, nrows(hb)), zero_matrix(ZZ, nrows(hb), 1))
@show c_in_hb
#TODO: form the monomial in OO(U) and collect these to local generators of the ideal.
end
end
#TODO: Form the ideal sheaf and the associated Weil divisor.
end

21 changes: 16 additions & 5 deletions experimental/Schemes/ToricDivisors/attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,24 @@ function forget_toric_structure(td::ToricDivisor)
end

# For method delegation.
function underlying_divisor(td::ToricDivisor; check::Bool=false)
function underlying_divisor(td::ToricDivisor; check::Bool=false, algorithm::Symbol=:direct)
if has_attribute(td, :underlying_divisor)
return get_attribute(td, :underlying_divisor)::WeilDivisor
end
X = scheme(td)
generating_divisors = _torusinvariant_weil_divisors(X; check)
result = sum(a*D for (a, D) in zip(coefficients(td), generating_divisors))
set_attribute!(td, :underlying_divisor=>result)
return result
if algorithm == :via_torus_invariant_prime_divisors
generating_divisors = _torusinvariant_weil_divisors(X; check)
result = sum(a*D for (a, D) in zip(coefficients(td), generating_divisors))
set_attribute!(td, :underlying_divisor=>result)
return result
elseif algorithm == :via_polymake_module_generators
a = coefficients(td)::Vector{ZZRingElem}
pos = [(c >= 0 ? c : zero(ZZ)) for c in a]
neg = [(c < 0 ? -c : zero(ZZ)) for c in a]
pos_div = _weil_divisor_via_polymake(X, pos)
neg_div = _weil_divisor_via_polymake(X, neg)
return pos_div - neg_div
else
error("algorithm not found")
end
end
Loading