packages feed

tropical 0.0.0.1 → 0.0.0.2

raw patch · 2 files changed

+59/−9 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Data.Semiring.Tropical: (.*.) :: Semiring s => s -> s -> s
+ Data.Semiring.Tropical: (.+.) :: Semiring s => s -> s -> s
+ Data.Semiring.Tropical: one :: Semiring s => s
+ Data.Semiring.Tropical: type TropicalOperator a = Operator (Tropical a)
+ Data.Semiring.Tropical: zero :: Semiring s => s
- Data.Semiring.Tropical: (./.) :: Real a => Operator (Tropical a)
+ Data.Semiring.Tropical: (./.) :: Real a => TropicalOperator a
- Data.Semiring.Tropical: (.^.) :: Real a => Operator (Tropical a)
+ Data.Semiring.Tropical: (.^.) :: Real a => TropicalOperator a

Files

src/Data/Semiring/Tropical.hs view
@@ -7,13 +7,46 @@ Stability    : experimental Portability  : Linux -This file just contains the minimal definition of "tropical," meaning-any tropical object has to be an ordered semiring.+This is a module for Tropical numbers. If you don't know what those are, read+<http://en.wikipedia.org/wiki/Tropical_geometry this Wikipedia entry>. +Tropical numbers form a 'Semiring'. Semirings are like+<https://en.wikipedia.org/wiki/Ring_(mathematics) normal rings>, but+you can't subtract.++The Tropical semiring, or 𝕋, is {ℝ ∪ {∞}, ⊕, ⊙}. Those are, in Haskell+terms, 'Real', 'Infinity', '(.+.)', and '(.*.)', respectively.++Tropical addition and multiplication are++a ⊕ b = min {a, b}, ∀ a, b ∈ 𝕋++a ⊙ b = a + b, ∀ a, b ∈ 𝕋+ -} -module Data.Semiring.Tropical where+module Data.Semiring.Tropical+  (+  -- * Tropical things+  -- +  -- +    Tropical(..) +  -- ** Tropical operations+  , (.+.)+  , (.*.)+  , (./.)+  , (.^.)++  -- ** Helper Things+  , Operator+  , TropicalOperator+  , zero+  , one+  )++where+ import Data.Semiring  -- |Tropical numbers are like real numbers, except zero is the same@@ -22,8 +55,25 @@                           | Infinity                    -- ^Infinity   deriving (Eq, Ord, Show) +-- |Helper type for binary operators   type Operator a = a -> a -> a+-- |An operator over something tropical+type TropicalOperator a = Operator (Tropical a)  +-- | Some notes - +-- +-- Tropical addition is the same as taking the minimum. Because+-- +-- min {a, ∞} = a, ∀ a ∈ ℝ+-- +-- 'Infinity' is the additive identity, or 'zero', in Semiring terms. +-- +-- Tropical multiplication is the sum. Because +-- +-- a + 0 = 0, ∀ a ∈ ℝ+-- +-- @Tropical 0@ is the multiplicative identity, or 'one' in Semiring+-- terms. instance Real a => Semiring (Tropical a) where   -- |Tropical addition is the same as taking the minimum   a .+. b = min a b@@ -39,15 +89,15 @@  -- |Tropical division. Remember, if Infinity is tropical zero, then -- you can't divide by it!-(./.) :: Real a => Operator (Tropical a)+(./.) :: Real a => TropicalOperator a _ ./. Infinity          = undefined Infinity ./. _          = Infinity a ./. b                 = Tropical $ (realValue a) - (realValue b) --- -- |Tropical exponentiation - same as classical multiplication. A--- -- mildly interesting correlary is that tropical exponentiation is--- -- commutative. That is, y .^. x = x .^. y, for x and y tropical.-(.^.) :: Real a => Operator (Tropical a)+-- |Tropical exponentiation - same as classical multiplication. A+-- mildly interesting correlary is that tropical exponentiation is+-- commutative. That is, y .^. x = x .^. y, for x and y tropical.+(.^.) :: Real a => TropicalOperator a a .^. b   | Infinity==a || Infinity==b  = Infinity   | otherwise                   = Tropical $ (realValue a) * (realValue b)
tropical.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                 tropical-version:              0.0.0.1+version:              0.0.0.2 synopsis:             A library for tropical mathematics. description:   Tropical numbers are the same as real numbers, except the operations are