Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- type Free = Representable
- newtype Vec a b = Vec {
- runVec :: b -> a
- vmap :: Lin a b c -> Vec a c -> Vec a b
- join :: Algebra a b => Vec a (b, b) -> Vec a b
- init :: Unital a b => a -> Vec a b
- (!*) :: Vec a b -> Cov a b -> a
- (*!) :: Cov a b -> Vec a b -> a
- (!*!) :: Algebra a b => Vec a b -> Vec a b -> Vec a b
- newtype Cov a c = Cov {
- runCov :: (c -> a) -> a
- images :: Semiring a => Foldable f => f (a, c) -> Cov a c
- cmap :: Lin a b c -> Cov a b -> Cov a c
- cojoin :: Coalgebra a c => Cov a (c, c) -> Cov a c
- coinit :: Counital a c => Cov a c
- comult :: Coalgebra a c => Cov a c -> Cov a c -> Cov a c
- newtype Lin a b c = Lin {
- runLin :: (c -> a) -> b -> a
- type End a b = Lin a b b
- image :: Semiring a => (b -> [(a, c)]) -> Lin a b c
- invmap :: (a1 -> a2) -> (a2 -> a1) -> Lin a1 b c -> Lin a2 b c
- augment :: Semiring a => Lin a b c -> b -> a
- (!#) :: Free f => Free g => Lin a (Rep f) (Rep g) -> g a -> f a
- (#!) :: Free f => Free g => g a -> Lin a (Rep f) (Rep g) -> f a
- (!#!) :: Lin a c d -> Lin a b c -> Lin a b d
- braid :: Lin a (b, c) (c, b)
- cobraid :: Lin a (b + c) (c + b)
- split :: (b -> (b1, b2)) -> Lin a b1 c -> Lin a b2 c -> Lin a b c
- cosplit :: ((c1 + c2) -> c) -> Lin a b c1 -> Lin a b c2 -> Lin a b c
- projl :: Free f => Free g => (f ++ g) a -> f a
- projr :: Free f => Free g => (f ++ g) a -> g a
- compl :: Free f1 => Free f2 => Free g => Lin a (Rep f1) (Rep f2) -> (f2 ** g) a -> (f1 ** g) a
- compr :: Free f => Free g1 => Free g2 => Lin a (Rep g1) (Rep g2) -> (f ** g2) a -> (f ** g1) a
- complr :: Free f1 => Free f2 => Free g1 => Free g2 => Lin a (Rep f1) (Rep f2) -> Lin a (Rep g1) (Rep g2) -> (f2 ** g2) a -> (f1 ** g1) a
- diagonal :: Algebra a b => Lin a b (b, b)
- codiagonal :: Coalgebra a c => Lin a (c, c) c
- initial :: Unital a b => Lin a b ()
- coinitial :: Counital a c => Lin a () c
- convolve :: Algebra a b => Coalgebra a c => Lin a b c -> Lin a b c -> Lin a b c
Types
type Free = Representable Source #
Vectors
A vector in a vector space or free semimodule.
Equivalent to Op.
Vectors transform contravariantly as a function of their bases.
See https://en.wikipedia.org/wiki/Covariance_and_contravariance_of_vectors#Definition.
Instances
Bisemimodule a a a => Bisemimodule a a (Vec a b) Source # | |
Semiring a => RightSemimodule a (Vec a b) Source # | |
Semiring a => LeftSemimodule a (Vec a b) Source # | |
(Additive - Semigroup) a => Semigroup (Additive (Vec a b)) Source # | |
(Additive - Monoid) a => Monoid (Additive (Vec a b)) Source # | |
Contravariant (Vec a) Source # | |
(Additive - Group) a => Group (Additive (Vec a b)) Source # | |
(Additive - Group) a => Loop (Additive (Vec a b)) Source # | |
(Additive - Group) a => Quasigroup (Additive (Vec a b)) Source # | |
(Additive - Group) a => Magma (Additive (Vec a b)) Source # | |
Category Vec Source # | |
Semiring a => RightSemimodule (End a b) (Vec a b) Source # | |
Semiring a => LeftSemimodule (End a b) (Vec a b) Source # | |
Semiring a => Bisemimodule (End a b) (End a b) (Vec a b) Source # | |
vmap :: Lin a b c -> Vec a c -> Vec a b Source #
Use a linear transformation to map over a vector space.
Note that the basis transforms https://en.wikipedia.org/wiki/Covariant_transformation#Contravariant_transformation contravariantly.
join :: Algebra a b => Vec a (b, b) -> Vec a b Source #
Obtain a vector from a vector on the tensor product space.
(!*!) :: Algebra a b => Vec a b -> Vec a b -> Vec a b infixr 7 Source #
Multiplication operator on an algebra over a free semimodule.
>>>
flip runVec E22 $ (vec $ V2 1 2) !*! (vec $ V2 7 4)
8
Caution in general mult
needn't be commutative, nor associative.
Covectors
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.
Co-vectors transform covariantly as a function of their bases.
See https://en.wikipedia.org/wiki/Covariance_and_contravariance_of_vectors#Definition.
Instances
Bisemimodule a a a => Bisemimodule a a (Cov a b) Source # | |
Semiring a => RightSemimodule a (Cov a b) Source # | |
Semiring a => LeftSemimodule a (Cov a b) Source # | |
Monad (Cov a) Source # | |
Functor (Cov a) Source # | |
Applicative (Cov a) Source # | |
(Additive - Semigroup) a => Semigroup (Additive (Cov a b)) Source # | |
(Additive - Monoid) a => Monoid (Additive (Cov a b)) Source # | |
(Additive - Monoid) a => Alternative (Cov a) Source # | |
(Additive - Monoid) a => MonadPlus (Cov a) Source # | |
(Additive - Group) a => Group (Additive (Cov a b)) Source # | |
(Additive - Group) a => Loop (Additive (Cov a b)) Source # | |
(Additive - Group) a => Quasigroup (Additive (Cov a b)) Source # | |
(Additive - Group) a => Magma (Additive (Cov a b)) Source # | |
Sieve (Lin a) (Cov a) Source # | |
Defined in Data.Semimodule.Free | |
Counital a b => RightSemimodule (End a b) (Cov a b) Source # | |
Counital a b => LeftSemimodule (End a b) (Cov a b) Source # | |
Counital a b => Bisemimodule (End a b) (End a b) (Cov a b) Source # | |
images :: Semiring a => Foldable f => f (a, c) -> Cov a c Source #
Obtain a covector from a linear combination of basis elements.
>>>
images [(2, E31),(3, E32)] !* vec (V3 1 1 1) :: Int
5
cmap :: Lin a b c -> Cov a b -> Cov a c Source #
Use a linear transformation to map over a dual space.
Note that the basis transforms covariantly.
cojoin :: Coalgebra a c => Cov a (c, c) -> Cov a c Source #
Obtain a covector from a covector on the tensor product space.
comult :: Coalgebra a c => Cov a c -> Cov a c -> Cov a c infixr 7 Source #
Multiplication operator on a coalgebra over a free semimodule.
>>>
flip runCov (e2 1 1) $ comult (cov $ V2 1 2) (cov $ V2 7 4)
11
Caution in general comult
needn't be commutative, nor coassociative.
Linear transformations
A linear transformation between free semimodules indexed with bases b and c.
f!#
x+
y = (f!#
x) + (f!#
y) f!#
(r.*
x) = r.*
(f!#
x)
Caution: You must ensure these laws hold when using the default constructor.
Instances
type End a b = Lin 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)]) -> Lin a b c Source #
Create a Lin
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 => Lin a (Rep f) (Rep g) -> g a -> f a infixr 2 Source #
Apply a transformation to a vector.
(#!) :: Free f => Free g => g a -> Lin a (Rep f) (Rep g) -> f a infixl 2 Source #
Apply a transformation to a vector.
Dimensional transforms
braid :: Lin a (b, c) (c, b) Source #
Swap components of a tensor product.
This is equivalent to a matrix transpose.
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 => Lin 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 => Lin 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 => Lin a (Rep f1) (Rep f2) -> Lin a (Rep g1) (Rep g2) -> (f2 ** g2) a -> (f1 ** g1) a Source #
Algebraic transforms
codiagonal :: Coalgebra a c => Lin a (c, c) c Source #