Common library for algebraic structures. Has the advantage of automatically inferring lots of useful structure, especially
in the writing of linear programs. For example, here are several ways of writing
3 x - 4 y + z:
gsum [3 *& x, (-4) *^ var y, var z] linCombination [(3, x), (-4, y), (1, z)] 3 *& x ^-^ 4 *& y ^+^ var z
In addition, if we have two functions
g, we can construct linear combinations of those functions, using
exactly the same syntax. Moreover, we can multiply functions with
Double coefficients by
Rational values successfully.
This module is intended to offer as much generality as possible without getting in your way.
- class Group g where
- class Group r => Ring r where
- class Ring f => Field f where
- class (Ring r, Group m) => Module r m where
- (*^) :: r -> m -> m
- class (Module f v, Field f) => VectorSpace f v
- type Poly = 
- varPoly :: Ring r => Poly r
- type GroupRing r g = Map g r
- type LinFunc = Map
- gsum :: Group g => [g] -> g
- combination :: Module r m => [(r, m)] -> m
- evalPoly :: (Module r m, Ring m) => Poly r -> m -> m
- var :: (Ord v, Ring c) => v -> LinFunc v c
- varSum :: (Ord v, Ring c) => [v] -> LinFunc v c
- (*&) :: (Ord v, Ring c) => c -> v -> LinFunc v c
- linCombination :: (Ord v, Num r) => [(r, v)] -> LinFunc v r
|Integral a => Group (Ratio a)|
|Group g => Group (IntMap g)|
|Group g => Group (Poly g)|
|Group g => Group (a -> g)|
|(Group g1, Group g2) => Group (g1, g2)|
|(Ord k, Group g) => Group (Map k g)|
|(Ord v, Group c) => Group (LinExpr v c)|
|(Group g1, Group g2, Group g3) => Group (g1, g2, g3)|
|(Group g1, Group g2, Group g3, Group g4) => Group (g1, g2, g3, g4)|
The algebraic structure of a unital ring. Assumes that the additive operation forms an abelian group, that the multiplication operation forms a group, and that multiplication distributes.
|(Group (Ratio a), Integral a) => Ring (Ratio a)|
|(Group (Poly r), Ring r) => Ring (Poly r)|
The polynomial ring.
|(Group (a -> r), Ring r) => Ring (a -> r)|
The function ring.
|(Group (GroupRing r g), Ord g, Group g, Ring r) => Ring (GroupRing r g)|
The group ring.
The algebraic structure of a module. A vector space is a module with coefficients in a field.
A way of forming a ring from functions. See http://en.wikipedia.org/wiki/Group_ring.
is a linear combination of variables of type
LinFunc v c
v with coefficients
c. Formally, this is the free
Given a collection of vectors and scaling coefficients, returns this linear combination.
Specialized methods on linear functions
Given a variable
v, returns the function equivalent to