TropicalNumbers
November 2, 2025 · View on GitHub
This package implements tropical numbers and tropical algebras in Julia. Tropical algebra is also known as the semiring algebra, which is a set equipped with two binary operations and , called addition and multiplication, such that:
- is a monoid with identity element called ;
- is a monoid with identity element called ;
- Addition is commutative;
- Multiplication by the additive identity annihilates ;
- Multiplication left- and right-distributes over addition;
- Explicitly stated, is a commutative monoid.
Installation
To install this package, press ] in Julia REPL to enter package mode, then type
pkg> add TropicalNumbers
Using
A Topical algebra can be described as a tuple , where is the set, and are the opeartions and , are their identity element, respectively. In this package, the following tropical algebras are implemented:
TropicalAndOr: ;TropicalBitwise: (\mathbb{R}, |, \\&, 0, \sim 0)Tropical(TropicalMaxPlus): ;TropicalMinPlus: ;TropicalMaxMul: .TropicalMaxMin: .
julia> using TropicalNumbers
julia> Tropical(3) * Tropical(4)
Tropical(7)
julia> TropicalMaxMul(3) * TropicalMaxMul(4)
TropicalMaxMul(12)
Warnings
TropicalMaxPlusis an alias ofTropical.TropicalMaxMulshould not contain negative numbers. However, this package does not check the data validity. Not only for performance reason, but also for future GPU support.
Why another tropical number?
Related packages include
These packages include unnecessary fields in its tropical numbers, such as isinf. However, Inf and -Inf can be used directly for floating point numbers, which is more memory efficient and computationally cheap. TropicalNumbers is designed for high performance matrix multiplication on both CPU and GPU.
Ecosystem
- TropicalGEMM.jl: The BLAS package for tropical numbers.
- CuTropicalGEMM.jl, The GPU version of TropicalGEMM.