Portability | portable |
---|---|

Stability | provisional |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Safe Haskell | Safe-Inferred |

Operations on free vector spaces.

- (^+^) :: (Applicative f, Num a) => f a -> f a -> f a
- gnegate :: (Functor f, Num a) => f a -> f a
- (^-^) :: (Applicative f, Num a) => f 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
- lerp :: (Applicative f, Num a) => a -> f a -> f a -> f a
- basis :: (Applicative t, Traversable t, Num a) => [t a]
- basisFor :: (Traversable t, Enum a, Num a) => t a -> [t a]

# Documentation

(^+^) :: (Applicative f, Num a) => f a -> f a -> f aSource

Compute the sum of two vectors

`>>>`

V2 4 6`V2 1 2 ^+^ V2 3 4`

gnegate :: (Functor f, Num a) => f a -> f aSource

Compute the negation of a vector

`>>>`

V2 (-2) (-4)`gnegate (V2 2 4)`

(^-^) :: (Applicative f, Num a) => f a -> f a -> f aSource

Compute the difference between two vectors

`>>>`

V2 1 4`V2 4 5 - V2 3 1`

(^*) :: (Functor f, Num a) => f a -> a -> f aSource

Compute the right scalar product

`>>>`

V2 6 8`V2 3 4 ^* 2`

(*^) :: (Functor f, Num a) => a -> f a -> f aSource

Compute the left scalar product

`>>>`

V2 6 8`2 *^ V2 3 4`

(^/) :: (Functor f, Fractional a) => f a -> a -> f aSource

Compute division by a scalar on the right.

lerp :: (Applicative f, Num a) => a -> f a -> f a -> f aSource

Linearly interpolate between two vectors.

basis :: (Applicative t, Traversable t, Num a) => [t a]Source

Produce a default basis for a vector space. If the dimensionality
of the vector space is not statically known, see `basisFor`

.

basisFor :: (Traversable t, Enum a, Num a) => t a -> [t a]Source

Produce a default basis for a vector space from which the argument is drawn.