rings-0.1.1.1: Ring-like objects.

Safe HaskellSafe
LanguageHaskell2010

Data.Semimodule.Transform

Synopsis

Documentation

type (**) f g = Compose f g infixr 2 Source #

A tensor product of semimodule morphisms.

type (++) f g = Product f g infixr 1 Source #

A direct sum of free semimodule elements.

newtype Dual a c Source #

Linear functionals from elements of a free semimodule to a scalar.

f !* (x + y) = (f !* x) + (f !* y)
f !* (x .* a) = a * (f !* x)

Caution: You must ensure these laws hold when using the default constructor.

Constructors

Dual 

Fields

Instances
RightSemimodule r s => RightSemimodule r (Dual s m) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

rscale :: r -> Dual s m -> Dual s m Source #

LeftSemimodule r s => LeftSemimodule r (Dual s m) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

lscale :: r -> Dual s m -> Dual s m Source #

Monad (Dual a) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

(>>=) :: Dual a a0 -> (a0 -> Dual a b) -> Dual a b #

(>>) :: Dual a a0 -> Dual a b -> Dual a b #

return :: a0 -> Dual a a0 #

fail :: String -> Dual a a0 #

Functor (Dual a) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

fmap :: (a0 -> b) -> Dual a a0 -> Dual a b #

(<$) :: a0 -> Dual a b -> Dual a a0 #

Applicative (Dual a) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

pure :: a0 -> Dual a a0 #

(<*>) :: Dual a (a0 -> b) -> Dual a a0 -> Dual a b #

liftA2 :: (a0 -> b -> c) -> Dual a a0 -> Dual a b -> Dual a c #

(*>) :: Dual a a0 -> Dual a b -> Dual a b #

(<*) :: Dual a a0 -> Dual a b -> Dual a a0 #

Coalgebra a b => Semigroup (Multiplicative (Dual a b)) Source # 
Instance details

Defined in Data.Semimodule.Transform

(Additive - Semigroup) a => Semigroup (Additive (Dual a b)) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

(<>) :: Additive (Dual a b) -> Additive (Dual a b) -> Additive (Dual a b) #

sconcat :: NonEmpty (Additive (Dual a b)) -> Additive (Dual a b) #

stimes :: Integral b0 => b0 -> Additive (Dual a b) -> Additive (Dual a b) #

Counital a b => Monoid (Multiplicative (Dual a b)) Source # 
Instance details

Defined in Data.Semimodule.Transform

(Additive - Monoid) a => Monoid (Additive (Dual a b)) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

mempty :: Additive (Dual a b) #

mappend :: Additive (Dual a b) -> Additive (Dual a b) -> Additive (Dual a b) #

mconcat :: [Additive (Dual a b)] -> Additive (Dual a b) #

(Additive - Monoid) a => Alternative (Dual a) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

empty :: Dual a a0 #

(<|>) :: Dual a a0 -> Dual a a0 -> Dual a a0 #

some :: Dual a a0 -> Dual a [a0] #

many :: Dual a a0 -> Dual a [a0] #

(Additive - Monoid) a => MonadPlus (Dual a) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

mzero :: Dual a a0 #

mplus :: Dual a a0 -> Dual a a0 -> Dual a a0 #

(Additive - Group) a => Group (Additive (Dual a b)) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

inv :: Additive (Dual a b) -> Additive (Dual a b) #

greplicate :: Integer -> Additive (Dual a b) -> Additive (Dual a b) #

(Additive - Group) a => Loop (Additive (Dual a b)) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

lempty :: Additive (Dual a b) #

lreplicate :: Natural -> Additive (Dual a b) -> Additive (Dual a b) #

(Additive - Group) a => Quasigroup (Additive (Dual a b)) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

(//) :: Additive (Dual a b) -> Additive (Dual a b) -> Additive (Dual a b) #

(\\) :: Additive (Dual a b) -> Additive (Dual a b) -> Additive (Dual a b) #

(Additive - Group) a => Magma (Additive (Dual a b)) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

(<<) :: Additive (Dual a b) -> Additive (Dual a b) -> Additive (Dual a b) #

(Ring a, Counital a b) => Ring (Dual a b) Source # 
Instance details

Defined in Data.Semimodule.Transform

Counital a b => Semiring (Dual a b) Source # 
Instance details

Defined in Data.Semimodule.Transform

Coalgebra a b => Presemiring (Dual a b) Source # 
Instance details

Defined in Data.Semimodule.Transform

Counital r m => RightSemimodule (Dual r m) (Dual r m) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

rscale :: Dual r m -> Dual r m -> Dual r m Source #

Counital r m => LeftSemimodule (Dual r m) (Dual r m) Source # 
Instance details

Defined in Data.Semimodule.Transform

Methods

lscale :: Dual r m -> Dual r m -> Dual r m Source #

image' :: Semiring a => Foldable f => f (a, c) -> Dual a c Source #

Create a Dual from a linear combination of basis vectors.

>>> image' [(2, E31),(3, E32)] !* V3 1 1 1 :: Int
5

toTran :: (b -> Dual a c) -> Tran a b c Source #

Obtain a linear transfrom from a linear functional.

fromTran :: Tran a b c -> b -> Dual a c Source #

Obtain a linear functional from a linear transform.

(!*) :: Free f => Dual a (Rep f) -> f a -> a infixr 3 Source #

Apply a linear functional to a vector.

(*!) :: Free f => f a -> Dual a (Rep f) -> a infixl 3 Source #

Apply a linear functional to a vector.

type Endo a b = Tran a b b Source #

An endomorphism over a free semimodule.

>>> one + two !# V2 1 2 :: V2 Double
V2 3.0 6.0

image :: Semiring a => (b -> [(a, c)]) -> Tran a b c Source #

Create a Tran from a linear combination of basis vectors.

>>> image (e2 [(2, E31),(3, E32)] [(1, E33)]) !# V3 1 1 1 :: V2 Int
V2 5 1

(!#) :: Free f => Free g => Tran a (Rep f) (Rep g) -> g a -> f a infixr 2 Source #

Apply a transformation to a vector.

(#!) :: Free f => Free g => g a -> Tran a (Rep f) (Rep g) -> f a infixl 2 Source #

Apply a transformation to a vector.

(!#!) :: Tran a c d -> Tran a b c -> Tran a b d infix 2 Source #

Compose two transformations.

dimap' :: (b1 -> b2) -> (c1 -> c2) -> Tran a b2 c1 -> Tran a b1 c2 Source #

Tran is a profunctor in the category of semimodules.

Caution: Arbitrary mapping functions may violate linearity.

>>> dimap' id (e3 True True False) (arr id) !# 4 :+ 5 :: V3 Int
V3 5 5 4

lmap' :: (b1 -> b2) -> Tran a b2 c -> Tran a b1 c Source #

rmap' :: (c1 -> c2) -> Tran a b c1 -> Tran a b c2 Source #

invmap :: (a1 -> a2) -> (a2 -> a1) -> Tran a1 b c -> Tran a2 b c Source #

Tran is an invariant functor.

See also http://comonad.com/reader/2008/rotten-bananas/.

braid :: Tran a (b, c) (c, b) Source #

Swap components of a tensor product.

cobraid :: Tran a (b + c) (c + b) Source #

Swap components of a direct sum.

commutator :: (Additive - Group) a => Endo a b -> Endo a b -> Endo a b Source #

Commutator or Lie bracket of two semimodule endomorphisms.

split :: (b -> (b1, b2)) -> Tran a b1 c -> Tran a b2 c -> Tran a b c Source #

TODO: Document

cosplit :: ((c1 + c2) -> c) -> Tran a b c1 -> Tran a b c2 -> Tran a b c Source #

TODO: Document

projl :: Free f => Free g => (f ++ g) a -> f a Source #

Project onto the left-hand component of a direct sum.

projr :: Free f => Free g => (f ++ g) a -> g a Source #

Project onto the right-hand component of a direct sum.

compl :: Free f1 => Free f2 => Free g => Tran a (Rep f1) (Rep f2) -> (f2 ** g) a -> (f1 ** g) a Source #

Left (post) composition with a linear transformation.

compr :: Free f => Free g1 => Free g2 => Tran a (Rep g1) (Rep g2) -> (f ** g2) a -> (f ** g1) a Source #

Right (pre) composition with a linear transformation.

complr :: Free f1 => Free f2 => Free g1 => Free g2 => Tran a (Rep f1) (Rep f2) -> Tran a (Rep g1) (Rep g2) -> (f2 ** g2) a -> (f1 ** g1) a Source #

Left and right composition with a linear transformation.

 complr f g = compl f >>> compr g