Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
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
6 changes: 6 additions & 0 deletions src/Oscar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ function __init__()
Pkg.is_manifest_current(dirname(Base.active_project())))
@warn "Project dependencies might have changed, please run `]up` or `]resolve`."
end

# Temporary workaround to allow access to Singular's tropicalVariety command
# see https://github.com/oscar-system/Oscar.jl/issues/5392
# see TropicalGeometry/variety_prime.jl
Singular.libSingular.load_library("tropical.lib")
Singular.call_interpreter("proc tropicalVariety_as_string(ideal I, list #) { if(size(#)==0) { return(string(tropicalVariety(I))); }; return(string(tropicalVariety(I,number(#[1])))); }")
end

const PROJECT_TOML = Pkg.TOML.parsefile(joinpath(@__DIR__, "..", "Project.toml"))
Expand Down
1 change: 0 additions & 1 deletion src/TropicalGeometry/variety.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ julia> vertices(TropI_3)
```
"""
function tropical_variety(I::MPolyIdeal, nu::TropicalSemiringMap=tropical_semiring_map(coefficient_ring(I)); weighted_polyhedral_complex_only::Bool=false, skip_saturation::Bool=false, skip_decomposition::Bool=false)

if !skip_saturation
###
# If saturation requested, saturate `I`
Expand Down
24 changes: 7 additions & 17 deletions src/TropicalGeometry/variety_prime.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@ function tropical_variety_prime(I::MPolyIdeal, nu::TropicalSemiringMap; weighted
return dehomogenize_post_tropicalization(TropIh)
end


# trivial valuation
function tropical_variety_prime_singular(I::MPolyIdeal, nu::TropicalSemiringMap{QQField,Nothing,<:Union{typeof(min),typeof(max)}}; weighted_polyhedral_complex_only::Bool=false)
R = base_ring(I)
singularCommand = join(["ring r=0,("*join(string.(symbols(R)),",")*"),dp;",
"ideal I = "*join(string.(gens(I)), ",")*";",
"if (!defined(tropicalVariety)) { LIB \"tropical.lib\"; };",
"fan TropI = tropicalVariety(I);",
"string TropIString = string(TropI);"])
Singular.call_interpreter(singularCommand)
TropIString = Singular.lookup_library_symbol("Top", "TropIString")

sI = Oscar.singular_generators(I)
TropIString = Singular.low_level_caller("tropical", "tropicalVariety_as_string", sI)

Sigma = gfan_fan_string_to_oscar_complex(TropIString,convention(nu)==max,false)
TropI = compute_weights_and_construct_tropical_variety(Sigma,I,nu)
if !weighted_polyhedral_complex_only
Expand All @@ -40,14 +37,8 @@ end

# p-adic valuation
function tropical_variety_prime_singular(I::MPolyIdeal, nu::TropicalSemiringMap{QQField,ZZRingElem,<:Union{typeof(min),typeof(max)}}; weighted_polyhedral_complex_only::Bool=false)
R = base_ring(I)
singularCommand = join(["ring r=0,("*join(string.(symbols(R)),",")*"),dp;",
"ideal I = "*join(string.(gens(I)), ",")*";",
"if (!defined(tropicalVariety)) { LIB \"tropical.lib\"; };",
"fan TropI = tropicalVariety(I,number("*string(uniformizer(nu))*"));",
"string TropIString = string(TropI);"])
Singular.call_interpreter(singularCommand)
TropIString = Singular.lookup_library_symbol("Top", "TropIString")
sI = Oscar.singular_generators(I)
TropIString = Singular.low_level_caller("tropical", "tropicalVariety_as_string", sI, Int(uniformizer_ring(nu)))
Sigma = gfan_fan_string_to_oscar_complex(TropIString,convention(nu)==max,true)
TropI = compute_weights_and_construct_tropical_variety(Sigma,I,nu)
if !weighted_polyhedral_complex_only
Expand Down Expand Up @@ -121,7 +112,6 @@ function gfan_fan_string_to_oscar_complex(input_string::String, negateFan::Bool=
coneIncidences = [ vcat(incidence,[originIndex]) for incidence in coneIncidences ]
return polyhedral_complex(IncidenceMatrix(coneIncidences), rayGenerators, rayIndices, linealityGenerators)
end

end


Expand Down
6 changes: 6 additions & 0 deletions test/TropicalGeometry/variety.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,11 @@
@test f_vector(TropV) == [1,3]

# general ideals, see doctests
I = grassmann_pluecker_ideal(2, 5)
nu = tropical_semiring_map(QQ, 3)
TropI = tropical_variety(I; skip_saturation=true, skip_decomposition=true)
@test f_vector(TropI) == [0, 0, 0, 0, 0, 1, 10, 15]
TropI = tropical_variety(I,nu; skip_saturation=true, skip_decomposition=true)
@test f_vector(TropI) == [0, 0, 0, 0, 0, 1, 10, 15]
end
end
Loading