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_MaxPlus :: (Vector x) -> Vector (MaxPlus x)
- pattern V_Viterbi :: (Vector x) -> Vector (Viterbi x)
- pattern V_MinPlus :: (Vector x) -> Vector (MinPlus x)
- pattern MV_MaxPlus :: (MVector s x) -> MVector s (MaxPlus x)
- pattern MV_Viterbi :: (MVector s x) -> MVector s (Viterbi x)
- pattern MV_MinPlus :: (MVector s x) -> MVector s (MinPlus x)
- newtype Viterbi x = Viterbi {
- getViterbi :: x
- (⊕) :: Semiring a => a -> a -> a
- (⊗) :: Semiring a => a -> a -> a
- nTimes :: Semiring a => Int -> 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
nTimes :: Semiring a => Int -> a -> a Source #
times
but done n
times.
TODO Include into type class to improve performance
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 # | |
ToJSON x => ToJSON (GSemiring z o x) Source # | |
Defined in Algebra.Structure.Semiring | |
FromJSON x => FromJSON (GSemiring z o x) Source # | |
NFData x => NFData (GSemiring zM oM x) Source # | |
Defined in Algebra.Structure.Semiring | |
(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 plus :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x # zero :: GSemiring zeroMonoid oneMonoid x # times :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x # one :: GSemiring zeroMonoid oneMonoid x # fromNatural :: Natural -> GSemiring zeroMonoid oneMonoid x # | |
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, +
, 0)
and the multiplicative monoid is (R, *
, 1).
For Bool
, the additive monoid is (Bool
, ||
, False
)
and the multiplicative monoid is (Bool
, &&
, True
).
Instances should satisfy the following laws:
- additive left identity
zero
+
x = x- additive right identity
x
+
zero
= x- additive associativity
x
+
(y+
z) = (x+
y)+
z- additive commutativity
x
+
y = y+
x- multiplicative left identity
one
*
x = x- multiplicative right identity
x
*
one
= x- multiplicative associativity
x
*
(y*
z) = (x*
y)*
z- left-distributivity of
*
over+
x
*
(y+
z) = (x*
y)+
(x*
z)- right-distributivity of
*
over+
(x
+
y)*
z = (x*
z)+
(y*
z)- annihilation
zero
*
x = x*
zero
=zero
plus, times, (zero, one | fromNatural)
:: a | |
-> a | |
-> a | Commutative Operation |
:: a | Commutative Unit |
:: a | |
-> a | |
-> a | Associative Operation |
:: a | Associative Unit |
:: Natural | |
-> a | Homomorphism of additive semigroups |