discokitty-0.1.0: DisCoCat implementation.

LicenseGPL-3
Safe HaskellSafe
LanguageHaskell2010

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 details

Defined in Discokitty.Models.Vectorspaces

Methods

showsPrec :: Int -> Vectorspace u m -> ShowS #

show :: Vectorspace u m -> String #

showList :: [Vectorspace u m] -> ShowS #

Dim (Vectorspace u m) Source # 
Instance details

Defined in Discokitty.Models.Vectorspaces

Methods

dim :: Vectorspace u m -> Int Source #

(Ord u, Eq u, Semiring m) => HasCups (Vectorspace u m) Source # 
Instance details

Defined in Discokitty.Models.Vectorspaces

Methods

cup :: Int -> Vectorspace u m -> Vectorspace u m -> Vectorspace u m Source #

cunit :: 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.