|Maintainer||Edward Kmett <email@example.com>|
Operations on free vector spaces.
- class Functor f => Additive f where
- negated :: (Functor f, Num a) => f a -> f a
- (^*) :: (Functor f, Num a) => f a -> a -> f a
- (*^) :: (Functor f, Num a) => a -> f a -> f a
- (^/) :: (Functor f, Fractional a) => f a -> a -> f a
- sumV :: (Foldable f, Additive v, Num a) => f (v a) -> v a
- basis :: (Applicative t, Traversable t, Num a) => [t a]
- basisFor :: (Traversable t, Enum a, Num a) => t a -> [t a]
- kronecker :: (Applicative t, Num a, Traversable t) => t a -> t (t a)
- outer :: (Functor f, Functor g, Num a) => f a -> g a -> f (g a)
A vector is an additive group with additional structure.
The zero vector
Compute the sum of two vectors
V2 1 2 ^+^ V2 3 4V2 4 6
Compute the difference between two vectors
V2 4 5 - V2 3 1V2 1 4
Linearly interpolate between two vectors.
Apply a function to merge the 'non-zero' components of two vectors, unioning the rest of the values.
|Additive ((->) b)|
|Ord k => Additive (Map k)|
|(Eq k, Hashable k) => Additive (HashMap k)|
|Dim n => Additive (V n)|
|Additive f => Additive (Point f)|
Compute the negation of a vector
negated (V2 2 4)V2 (-2) (-4)
Compute the right scalar product
V2 3 4 ^* 2V2 6 8
Compute the left scalar product
2 *^ V2 3 4V2 6 8
Compute division by a scalar on the right.
Sum over multiple vectors
sumV [V2 1 1, V2 3 4]V2 4 5
Produce a default basis for a vector space. If the dimensionality
of the vector space is not statically known, see
Produce a default basis for a vector space from which the argument is drawn.
Produce a diagonal matrix from a vector.