Safe Haskell | None |
---|---|
Language | Haskell2010 |
A set with two binary operations, one for addition (srplus
), one for
multiplication (srmul
). Together with a neutral element for srplus
,
named srzero
, and one for srmul
, named srone
.
Synopsis
- pattern V_Viterbi :: (Vector x) -> Vector (Viterbi x)
- pattern V_MinPlus :: (Vector x) -> Vector (MinPlus x)
- pattern V_MaxPlus :: (Vector x) -> Vector (MaxPlus x)
- pattern MV_Viterbi :: (MVector s x) -> MVector s (Viterbi x)
- pattern MV_MinPlus :: (MVector s x) -> MVector s (MinPlus x)
- pattern MV_MaxPlus :: (MVector s x) -> MVector s (MaxPlus x)
- newtype Viterbi x = Viterbi {
- getViterbi :: x
- (⊕) :: Semiring a => a -> a -> a
- (⊗) :: Semiring a => a -> a -> a
- newtype MinPlus x = MinPlus {
- getMinPlus :: x
- newtype MaxPlus x = MaxPlus {
- getMaxPlus :: x
- newtype GSemiring (zeroMonoid :: * -> *) (oneMonoid :: * -> *) (x :: *) = GSemiring {
- getSemiring :: x
- class Semiring a where
Documentation
The Viterbi SemiRing. It maximizes over the product.
Viterbi | |
|
Instances
The tropical MinPlus SemiRing. It minimizes over the sum.
MinPlus | |
|
Instances
The tropical MaxPlus SemiRing. It maximizes over the sum.
MaxPlus | |
|
Instances
newtype GSemiring (zeroMonoid :: * -> *) (oneMonoid :: * -> *) (x :: *) Source #
The generic semiring, defined over two Semigroup
and Monoid
constructions.
It can be used like this:
zero ∷ GSemiring Min Sum Int == maxBound
one ∷ GSemiring Min Sum Int == 0
It is generally useful to still provide explicit instances, since Min
requires a Bounded
instance.
GSemiring | |
|
Instances
Eq x => Eq (GSemiring zeroMonoid oneMonoid x) Source # | |
Ord x => Ord (GSemiring zeroMonoid oneMonoid x) Source # | |
Defined in Algebra.Structure.Semiring compare :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> Ordering # (<) :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> Bool # (<=) :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> Bool # (>) :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> Bool # (>=) :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> Bool # max :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x # min :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x # | |
Read x => Read (GSemiring zeroMonoid oneMonoid x) Source # | |
Show x => Show (GSemiring zeroMonoid oneMonoid x) Source # | |
Generic (GSemiring zeroMonoid oneMonoid x) Source # | |
(Semigroup (zeroMonoid x), Monoid (zeroMonoid x), Semigroup (oneMonoid x), Monoid (oneMonoid x), Coercible (zeroMonoid x) (GSemiring zeroMonoid oneMonoid x), Coercible (oneMonoid x) (GSemiring zeroMonoid oneMonoid x)) => Semiring (GSemiring zeroMonoid oneMonoid x) Source # | |
Defined in Algebra.Structure.Semiring | |
type Rep (GSemiring zeroMonoid oneMonoid x) Source # | |
Defined in Algebra.Structure.Semiring |
The class of semirings (types with two binary
operations and two respective identities). One
can think of a semiring as two monoids of the same
underlying type, with the first being commutative.
In the documentation, you will often see the first
monoid being referred to as additive
, and the second
monoid being referred to as multiplicative
, a typical
convention when talking about semirings.
For any type R with a Num
instance, the additive monoid is (R, '(Prelude.+)', 0)
and the multiplicative monoid is (R, '(Prelude.*)', 1).
For Bool
, the additive monoid is (Bool
, ||
, False
)
and the multiplicative monoid is (Bool
, &&
, True
).
Instances should satisfy the following laws:
- additive identity
x
+
zero
=zero
+
x = x- additive associativity
x
+
(y+
z) = (x+
y)+
z- additive commutativity
x
+
y = y+
x- multiplicative identity
x
*
one
=one
*
x = x- multiplicative associativity
x
*
(y*
z) = (x*
y)*
z- left- and right-distributivity of
*
over+
x
*
(y+
z) = (x*
y)+
(x*
z)(x
+
y)*
z = (x*
z)+
(y*
z)- annihilation
zero
*
x = x*
zero
=zero
:: a | |
-> a | |
-> a | Commutative Operation |
:: a | Commutative Unit |
:: a | |
-> a | |
-> a | Associative Operation |
:: a | Associative Unit |
Instances
Semiring Bool | |
Semiring Double | |
Semiring Float | |
Semiring Int | |
Semiring Int8 | |
Semiring Int16 | |
Semiring Int32 | |
Semiring Int64 | |
Semiring Integer | |
Semiring Natural | |
Semiring Word | |
Semiring Word8 | |
Semiring Word16 | |
Semiring Word32 | |
Semiring Word64 | |
Semiring () | |
Semiring CDev | |
Semiring CIno | |
Semiring CMode | |
Semiring COff | |
Semiring CPid | |
Semiring CSsize | |
Semiring CGid | |
Semiring CNlink | |
Semiring CUid | |
Semiring CCc | |
Semiring CSpeed | |
Semiring CTcflag | |
Semiring CRLim | |
Semiring Fd | |
Semiring CChar | |
Semiring CSChar | |
Semiring CUChar | |
Semiring CShort | |
Semiring CUShort | |
Semiring CInt | |
Semiring CUInt | |
Semiring CLong | |
Semiring CULong | |
Semiring CLLong | |
Semiring CULLong | |
Semiring CFloat | |
Semiring CDouble | |
Semiring CPtrdiff | |
Semiring CSize | |
Semiring CWchar | |
Semiring CSigAtomic | |
Defined in Data.Semiring plus :: CSigAtomic -> CSigAtomic -> CSigAtomic # zero :: CSigAtomic # times :: CSigAtomic -> CSigAtomic -> CSigAtomic # one :: CSigAtomic # | |
Semiring CClock | |
Semiring CTime | |
Semiring CUSeconds | |
Semiring CSUSeconds | |
Defined in Data.Semiring plus :: CSUSeconds -> CSUSeconds -> CSUSeconds # zero :: CSUSeconds # times :: CSUSeconds -> CSUSeconds -> CSUSeconds # one :: CSUSeconds # | |
Semiring CIntPtr | |
Semiring CUIntPtr | |
Semiring CIntMax | |
Semiring CUIntMax | |
Semiring WordPtr | |
Semiring IntPtr | |
Semiring Odds Source # | |
Semiring a => Semiring [a] | The Examples
|
Semiring a => Semiring (Maybe a) | |
Integral a => Semiring (Ratio a) | |
Semiring a => Semiring (IO a) | |
Ring a => Semiring (Complex a) | This instance can suffer due to floating point arithmetic. |
HasResolution a => Semiring (Fixed a) | |
Semiring (Predicate a) | |
Semiring a => Semiring (Equivalence a) | |
Defined in Data.Semiring plus :: Equivalence a -> Equivalence a -> Equivalence a # zero :: Equivalence a # times :: Equivalence a -> Equivalence a -> Equivalence a # one :: Equivalence a # | |
Semiring a => Semiring (Identity a) | |
Semiring a => Semiring (Dual a) | |
Semiring a => Semiring (Down a) | |
(Ord a, Monoid a) => Semiring (Set a) | The multiplication laws are satisfied for
any underlying |
(Storable a, Semiring a) => Semiring (Vector a) | |
(Unbox a, Semiring a) => Semiring (Vector a) | |
(Eq a, Hashable a, Monoid a) => Semiring (HashSet a) | The multiplication laws are satisfied for
any underlying |
Semiring a => Semiring (Vector a) | The Examples
|
(Precise a, RealFloat a) => Semiring (Log a) Source # | |
Num a => Semiring (WrappedNum a) | |
Defined in Data.Semiring plus :: WrappedNum a -> WrappedNum a -> WrappedNum a # zero :: WrappedNum a # times :: WrappedNum a -> WrappedNum a -> WrappedNum a # one :: WrappedNum a # | |
(Coercible Int a, Monoid a) => Semiring (IntSetOf a) | |
(Ord x, Semiring x) => Semiring (Viterbi x) Source # | TODO Shall we have generic instances, or specific ones like TODO Consider either a constraint |
(Ord x, Semiring x, NumericLimits x) => Semiring (MinPlus x) Source # | Be careful, if the numeric limits are hits, underflows, etc will happen. |
(Ord x, Semiring x, NumericLimits x) => Semiring (MaxPlus x) Source # | TODO Shall we have generic instances, or specific ones like TODO Consider either a constraint |
Semiring b => Semiring (a -> b) | |
Semiring a => Semiring (Op a b) | |
(Eq k, Hashable k, Monoid k, Semiring v) => Semiring (HashMap k v) | The multiplication laws are satisfied for
any underlying |
(Ord k, Monoid k, Semiring v) => Semiring (Map k v) | The multiplication laws are satisfied for
any underlying |
Semiring (Proxy a) | |
(Coercible Int k, Monoid k, Semiring v) => Semiring (IntMapOf k v) | |
Num (Discretized k2) => Semiring (Discretized k2) Source # | |
Defined in Numeric.Discretized plus :: Discretized k2 -> Discretized k2 -> Discretized k2 # zero :: Discretized k2 # times :: Discretized k2 -> Discretized k2 -> Discretized k2 # one :: Discretized k2 # | |
Semiring (Discretized t) => Semiring (DiscLogOdds t) Source # | |
Defined in Statistics.Odds plus :: DiscLogOdds t -> DiscLogOdds t -> DiscLogOdds t # zero :: DiscLogOdds t # times :: DiscLogOdds t -> DiscLogOdds t -> DiscLogOdds t # one :: DiscLogOdds t # | |
Num r => Semiring (Probability n r) Source # | |
Defined in Statistics.Probability plus :: Probability n r -> Probability n r -> Probability n r # zero :: Probability n r # times :: Probability n r -> Probability n r -> Probability n r # one :: Probability n r # | |
Semiring a => Semiring (Const a b) | |
(Semiring a, Applicative f) => Semiring (Ap f a) | |
(Semigroup (zeroMonoid x), Monoid (zeroMonoid x), Semigroup (oneMonoid x), Monoid (oneMonoid x), Coercible (zeroMonoid x) (GSemiring zeroMonoid oneMonoid x), Coercible (oneMonoid x) (GSemiring zeroMonoid oneMonoid x)) => Semiring (GSemiring zeroMonoid oneMonoid x) Source # | |
Defined in Algebra.Structure.Semiring |