Skip to content

Commit

Permalink
TropicalGeometry: added stable intersection linear spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
YueRen committed Sep 20, 2023
1 parent 578ddf1 commit bb074fb
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/TropicalGeometry/intersection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ function intersect_stably(TropV1::TropicalVarietySupertype{minOrMax,true}, TropV
# return Sigma12,mults12
end

# SUGGESTION: Add this to PolyhedralGeometry
function isempty(sigma::Polyhedron)
return dim(sigma)<0
end

function intersect_after_perturbation(sigma1::Polyhedron, sigma2::Polyhedron, perturbation::Vector{Int})

if dim(intersect(sigma1,sigma2))<0
if isempty(intersect(sigma1,sigma2))
return false
end

Expand Down Expand Up @@ -85,3 +90,32 @@ function tropical_intersection_multiplicity(sigma1::Polyhedron,sigma2::Polyhedro
snfB12 = snf(vcat(B1,B2))
return abs(prod([snfB12[i,i] for i in 1:ncols(snfB12)]))
end


# Todo: make this use algebraic_pluecker_vector if available
# Problem: the +/- in the formula of speyers paper
function intersect_stably(TropL1::TropicalLinearSpace{minOrMax,true}, TropL2::TropicalLinearSpace{minOrMax,true}) where minOrMax

plueckerIndices12 = Vector{Int}[]
plueckerVector12 = TropicalSemiringElem{typeof(minOrMax)}[]
d = codim(TropL1)+codim(TropL2)

for (I1,p1) in zip(pluecker_indices(TropL1),tropical_pluecker_vector(TropL1))
for (I2,p2) in zip(pluecker_indices(TropL2),tropical_pluecker_vector(TropL2))
I12 = intersect(I1,I2)
if length(I12)>d
continue
end

i = searchsortedfirst(plueckerIndices12,I12)
if i<=length(plueckerIndices12) && plueckerIndices12[i]==I12
plueckerVector12[i] += p1*p2
else
insert!(plueckerIndices12,i,I12)
insert!(plueckerVector12,i,p1*p2)
end
end
end

return tropical_linear_space(plueckerIndices12,plueckerVector12)
end

0 comments on commit bb074fb

Please sign in to comment.