-
Notifications
You must be signed in to change notification settings - Fork 120
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
ToricVarieties: Toric morphisms #1460
Conversation
5bf931f
to
4d3891f
Compare
68cdbe3
to
beade5c
Compare
2d15000
to
2480c5a
Compare
2480c5a
to
1ffae7e
Compare
46df69e
to
4b1e10a
Compare
4b1e10a
to
ea24ea3
Compare
ea24ea3
to
47e5d89
Compare
I just rebased to the latest master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid high nesting levels and long functions. If funtions become too long they should probably be broken up into shorter logical parts.
for i in 1:nrows(images_of_rays) | ||
for j in 1:length(codomain_variety_max_cones) | ||
if contains(codomain_variety_max_cones[j], [images_of_rays[i,k] for k in 1:ncols(images_of_rays)]) | ||
rayimage_maxcones_incidence_list[i] = j | ||
break | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicating a lot of checks, isn't it? Also I believe Max said that there is a way to avoid nested for loops, I think you can just separate the two params with a comma.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I was just confused. Can you not write something like images_of_rays[i,:]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also what if a ray is contained in several maximal cones?
images_of_rays = domain_variety_rays * matrix(grid_morphism(tm)) | ||
|
||
# for each image ray, find a max cone in the codomain toric variety which contains it | ||
codomain_variety_max_cones = maximal_cones(codomain_variety) | ||
rayimage_maxcones_incidence_list = [0 for i in 1:nrows(images_of_rays)] | ||
for i in 1:nrows(images_of_rays) | ||
for j in 1:length(codomain_variety_max_cones) | ||
if contains(codomain_variety_max_cones[j], [images_of_rays[i,k] for k in 1:ncols(images_of_rays)]) | ||
rayimage_maxcones_incidence_list[i] = j | ||
break | ||
end | ||
end | ||
end | ||
|
||
# form list of rays which are in maximal cones of the codomain variety | ||
codomain_variety_maxcone_ray_incidence = ray_indices(maximal_cones(codomain_variety)) | ||
r = rank(character_lattice(codomain_variety)) | ||
codomain_variety_rays_in_cones = [] | ||
for i in 1:length(codomain_variety_max_cones) | ||
matrix = zeros(Int,nrows(codomain_variety_rays),ncols(codomain_variety_rays)) | ||
for j in 1:nrows(codomain_variety_rays) | ||
if codomain_variety_maxcone_ray_incidence[i,j] | ||
for k in 1:ncols(codomain_variety_rays) | ||
matrix[j,k] = codomain_variety_rays[j,k] | ||
end | ||
end | ||
end | ||
push!(codomain_variety_rays_in_cones, matrix) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can actually use IncidenceMatrix
from Oscar and build an incidence matrix for the image rays in the target fan in hopefully less code along the lines of
julia> fc = normal_fan(cube(2));
julia> fh = normal_fan(hexagon);
julia> rh = collect(rays(fh))
6-element Vector{RayVector{fmpq}}:
[1, 0]
[0, 1]
[1, -1]
[-1, 1]
[-1, 0]
[0, -1]
julia> mc = collect(maximal_cones(fc))
4-element Vector{Cone{fmpq}}:
A polyhedral cone in ambient dimension 2
A polyhedral cone in ambient dimension 2
A polyhedral cone in ambient dimension 2
A polyhedral cone in ambient dimension 2
julia> image_incidences = IncidenceMatrix(nrays(fh), n_maximal_cones(fc))
6×4 IncidenceMatrix
[]
[]
[]
[]
[]
[]
julia> for i in 1:nrays(fh), j in 1:n_maximal_cones(fc)
image_incidences[i,j] = contains(mc[j], rh[i])
end
julia> image_incidences
6×4 IncidenceMatrix
[1, 3]
[1, 2]
[3]
[2]
[2, 4]
[3, 4]
Does this maybe simplify this method?
end | ||
end | ||
|
||
# return the map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# return the map |
Isn't this obvious from the line below starting with return
?
for i in 1:nrows(images_of_rays) | ||
current_row = images_of_rays[i,:] | ||
solution = false | ||
matrix_multiplier = 1 | ||
while !solution | ||
r = matrix_multiplier * current_row | ||
matrix_multiplier = matrix_multiplier + 1 | ||
m = matrix(ZZ,codomain_variety_rays_in_cones[rayimage_maxcones_incidence_list[i]]) | ||
solution = can_solve(transpose(m), transpose(r)) | ||
if solution | ||
current_row = solve(transpose(m), transpose(r)) | ||
current_row = transpose(current_row) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not while !can_solve(...)
? Also the matrix_multiplier
seems unneeded. You could just add images_of_rays[i,:]
to current_row
and addition might be faster than multiplication.
Thank you @lkastner for the detailed review. Based on your feedback, I believe there is a need to rethink and also redesign a couple of things here, in particular the function for the map between the torus invariant divisor class groups. Hence, I have reverted this PR into a draft for the time being. More shortly. |
47e5d89
to
1777389
Compare
Thank you @lkastner. I merge. |
This PR achieves the following: