Skip to content

Commit 02d1371

Browse files
committed
TropicalGeometry: exponentiation for tropical polynomials
1 parent f4298e2 commit 02d1371

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/TropicalGeometry/TropicalGeometry.jl

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
###############################################################################
66
include("semiring.jl")
77
include("semiring_map.jl")
8+
include("semiring_mpoly.jl")
89
include("matrix.jl")
910
include("poly.jl")
1011
include("homogenization.jl")
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
################################################################################
2+
#
3+
# Functionality for multivariate polynomials over tropical semirings
4+
# (alternatives for generic functions that do not work over tropical semirings)
5+
#
6+
################################################################################
7+
8+
# exponentiation has to be in multiple functions, otherwise calls become ambiguous
9+
# due to ^(a::AbstractAlgebra.Generic.MPoly{T}, b::Int64) where T<:RingElement
10+
# in AbstractAlgebra/src/generic/MPoly.jl:2257
11+
function Base.:(^)(a::Generic.MPoly{<:TropicalSemiringElem}, n::Int)
12+
@req n>=0 "polynomial exponentiation with negative exponent"
13+
return Generic.pow_rmul(a,n)
14+
end
15+
function Base.:(^)(a::Generic.MPoly{<:TropicalSemiringElem}, n::ZZRingElem)
16+
return Generic.pow_rmul(a,Int(n))
17+
end

test/TropicalGeometry/semiring.jl

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
@testset "characteristic" begin
2727
@test characteristic(T) == 0
2828
end
29+
30+
@testset "polynomial exponentiation" begin
31+
Tx, x = polynomial_ring(T, 1)
32+
f = x[1]^4 + 3*x[1]
33+
@test f^3 == f*f*f
34+
end
2935
end
3036

3137
end

0 commit comments

Comments
 (0)