algebra-3.1: Constructive abstract algebra

Safe Haskell None

Numeric.Map

Synopsis

# Documentation

newtype Map r b a Source

linear maps from elements of a free module to another free module over r

``` f \$# x + y = (f \$# x) + (f \$# y)
f \$# (r .* x) = r .* (f \$# x)
```

`Map r b a` represents a linear mapping from a free module with basis `a` over `r` to a free module with basis `b` over `r`.

Note well the reversed direction of the arrow, due to the contravariance of change of basis!

This way enables we can employ arbitrary pure functions as linear maps by lifting them using `arr`, or build them by using the monad instance for Map r b. As a consequence Map is an instance of, well, almost everything.

Constructors

 Map ((a -> r) -> b -> r)

Instances

 (Category (Map r), Category (Map r)) => PFunctor Either (Map r) (Map r) (Category (Map r), Category (Map r)) => PFunctor (,) (Map r) (Map r) (Category (Map r), Category (Map r)) => QFunctor Either (Map r) (Map r) (Category (Map r), Category (Map r)) => QFunctor (,) (Map r) (Map r) (PFunctor Either (Map r) (Map r), QFunctor Either (Map r) (Map r)) => Bifunctor Either (Map r) (Map r) (Map r) (PFunctor (,) (Map r) (Map r), QFunctor (,) (Map r) (Map r)) => Bifunctor (,) (Map r) (Map r) (Map r) Monad (Map r b) => MonadReader b (Map r b) (Semiring r, Additive (Map s b m), RightModule r s) => RightModule r (Map s b m) (Semiring r, Additive (Map s b m), LeftModule r s) => LeftModule r (Map s b m) Category (Map r) => Arrow (Map r) (Arrow (Map r), Monoidal r) => ArrowZero (Map r) (ArrowZero (Map r), Monoidal r) => ArrowPlus (Map r) Arrow (Map r) => ArrowChoice (Map r) Arrow (Map r) => ArrowApply (Map r) Category (Map r) (Cartesian (Map r), CoCartesian (Map r)) => Distributive (Map r) Cartesian (Map r) => CCC (Map r) (Symmetric (Map r) (Product (Map r)), Monoidal (Map r) (Product (Map r))) => Cartesian (Map r) (Monoidal (Map r) (Sum (Map r)), Symmetric (Map r) (Sum (Map r))) => CoCartesian (Map r) Semigroupoid (Map r) Associative (Map r) Either => Braided (Map r) Either Associative (Map r) (,) => Braided (Map r) (,) Braided (Map r) Either => Symmetric (Map r) Either Braided (Map r) (,) => Symmetric (Map r) (,) Associative (Map r) Either => Monoidal (Map r) Either Associative (Map r) (,) => Monoidal (Map r) (,) Bifunctor Either (Map r) (Map r) (Map r) => Associative (Map r) Either Bifunctor (,) (Map r) (Map r) (Map r) => Associative (Map r) (,) Monad (Map r b) Functor (Map r b) (Monad (Map r b), Monoidal r) => MonadPlus (Map r b) Functor (Map r b) => Applicative (Map r b) (Applicative (Map r b), Monoidal r) => Alternative (Map r b) (Alt (Map r b), Monoidal r) => Plus (Map r b) (Functor (Map r b), Additive r) => Alt (Map r b) Functor (Map r b) => Apply (Map r b) Apply (Map r b) => Bind (Map r b) (Additive (Map s b a), Abelian s) => Abelian (Map s b a) Additive r => Additive (Map r b a) (LeftModule Natural (Map s b a), RightModule Natural (Map s b a), Monoidal s) => Monoidal (Map s b a) (Additive (Map r b m), Abelian (Map r b m), Multiplicative (Map r b m), Coalgebra r m) => Semiring (Map r b m) Coalgebra r m => Multiplicative (Map r b m) (LeftModule Integer (Map s b a), RightModule Integer (Map s b a), Monoidal (Map s b a), Group s) => Group (Map s b a) (Multiplicative (Map r b m), CounitalCoalgebra r m) => Unital (Map r b m) (Semiring (Map r b m), Unital (Map r b m), Monoidal (Map r b m), Rig r, CounitalCoalgebra r m) => Rig (Map r b m) (Rig (Map r a m), Rng (Map r a m), Ring r, CounitalCoalgebra r m) => Ring (Map r a m) (Multiplicative (Map r b m), Commutative m, Coalgebra r m) => Commutative (Map r b m) (Semiring (Map r b m), Additive (Map r b m), Coalgebra r m) => RightModule (Map r b m) (Map r b m) (Semiring (Map r b m), Additive (Map r b m), Coalgebra r m) => LeftModule (Map r b m) (Map r b m)

(\$@) :: Map r b a -> b -> Covector r aSource

extract a linear functional from a linear map

multMap :: Coalgebra r c => Map r (c, c) cSource

memoMap :: HasTrie a => Map r a aSource

(inefficiently) combine a linear combination of basis vectors to make a map. arrMap :: (Monoidal r, Semiring r) => (b -> [(r, a)]) -> Map r b a arrMap f = Map \$ k b -> sum [ r * k a | (r, a) <- f b ]

Memoize the results of this linear map

comultMap :: Algebra r a => Map r a (a, a)Source

convolveMap :: (Algebra r a, Coalgebra r c) => Map r a c -> Map r a c -> Map r a cSource

convolution given an associative algebra and coassociative coalgebra