discokitty-0.1.0: DisCoCat implementation.

Discokitty.Models.Vectorspaces

Description

An implementation of the cups of the category of matrices over an arbitary semiring. In this module we call "vector space" to what would be more generally a module over a semiring. The representation is done using sparse vectors that do not include the elements of the basis whose element is zero. |

Synopsis

# Documentation

data Vectorspace u m Source #

A vector is given internally by a map representing the coefficients of each basis element.

Constructors

 Vector (Map [u] m)
Instances
 (Show m, Show u) => Show (Vectorspace u m) Source # Shows the coefficients of the vector. Instance detailsDefined in Discokitty.Models.Vectorspaces MethodsshowsPrec :: Int -> Vectorspace u m -> ShowS #show :: Vectorspace u m -> String #showList :: [Vectorspace u m] -> ShowS # Dim (Vectorspace u m) Source # Instance detailsDefined in Discokitty.Models.Vectorspaces Methodsdim :: Vectorspace u m -> Int Source # (Ord u, Eq u, Semiring m) => HasCups (Vectorspace u m) Source # Instance detailsDefined in Discokitty.Models.Vectorspaces Methodscup :: Int -> Vectorspace u m -> Vectorspace u m -> Vectorspace u m Source #

sparse :: (Ord u, Eq u, Semiring m) => [([u], m)] -> Vectorspace u m Source #

Creates a sparse vector from a list of basis elements multiplied by scalars.

fromList :: (Ord u, Eq u, Semiring m) => [([u], m)] -> Vectorspace u m Source #

fromMap :: Map [u] m -> Vectorspace u m Source #

Creates a sparse vector from a map assigning a scalar to each base element.

toMap :: Vectorspace u m -> Map [u] m Source #

Outputs a map assigning to each base element its coefficient.

class (Eq m, Ord m) => Semiring m where Source #

Methods

plus :: m -> m -> m Source #

mult :: m -> m -> m Source #

zero :: m Source #

unit :: m Source #

Instances
 Source # Instance detailsDefined in Discokitty.Examples.LesJustesVector Methods Source # Instance detailsDefined in Discokitty.Examples.LesJustesViterbi Methods Source # Instance detailsDefined in Discokitty.Examples.LesJustesVector Methods