Stability | experimental |
---|---|
Maintainer | conal@conal.net, andygill@ku.edu |
Safe Haskell | None |
Vector spaces
This version uses associated types instead of fundeps and requires ghc-6.10 or later
- module Data.AdditiveGroup
- class AdditiveGroup v => VectorSpace v where
- (^/) :: (VectorSpace v, s ~ Scalar v, Fractional s) => v -> s -> v
- (^*) :: (VectorSpace v, s ~ Scalar v) => v -> s -> v
- class (VectorSpace v, AdditiveGroup (Scalar v)) => InnerSpace v where
- lerp :: VectorSpace v => v -> v -> Scalar v -> v
- linearCombo :: VectorSpace v => [(v, Scalar v)] -> v
- magnitudeSq :: (InnerSpace v, s ~ Scalar v) => v -> s
- magnitude :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> s
- normalized :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> v
- project :: (InnerSpace v, s ~ Scalar v, Fractional s) => v -> v -> v
Documentation
module Data.AdditiveGroup
class AdditiveGroup v => VectorSpace v whereSource
Vector space v
.
VectorSpace Double | |
VectorSpace Float | |
VectorSpace Int | |
VectorSpace Integer | |
VectorSpace CSChar | |
VectorSpace CShort | |
VectorSpace CInt | |
VectorSpace CLong | |
VectorSpace CLLong | |
VectorSpace CFloat | |
VectorSpace CDouble | |
VectorSpace CIntMax | |
Integral a => VectorSpace (Ratio a) | |
(RealFloat v, VectorSpace v) => VectorSpace (Complex v) | |
VectorSpace v => VectorSpace (Maybe v) | |
VectorSpace v => VectorSpace (a -> v) | |
(VectorSpace u, ~ * s (Scalar u), VectorSpace v, ~ * s (Scalar v)) => VectorSpace (u, v) | |
(HasTrie a, VectorSpace v) => VectorSpace (:->: a v) | |
(HasTrie (Basis u), VectorSpace v) => VectorSpace (:-* u v) | |
(HasBasis a, HasTrie (Basis a), VectorSpace u, AdditiveGroup (Scalar u)) => VectorSpace (:> a u) | |
(VectorSpace u, ~ * s (Scalar u), VectorSpace v, ~ * s (Scalar v), VectorSpace w, ~ * s (Scalar w)) => VectorSpace (u, v, w) | |
(VectorSpace u, ~ * s (Scalar u), VectorSpace v, ~ * s (Scalar v), VectorSpace w, ~ * s (Scalar w), VectorSpace x, ~ * s (Scalar x)) => VectorSpace (u, v, w, x) |
(^/) :: (VectorSpace v, s ~ Scalar v, Fractional s) => v -> s -> vSource
Vector divided by scalar
(^*) :: (VectorSpace v, s ~ Scalar v) => v -> s -> vSource
Vector multiplied by scalar
class (VectorSpace v, AdditiveGroup (Scalar v)) => InnerSpace v whereSource
Adds inner (dot) products.
InnerSpace Double | |
InnerSpace Float | |
InnerSpace Int | |
InnerSpace Integer | |
InnerSpace CSChar | |
InnerSpace CShort | |
InnerSpace CInt | |
InnerSpace CLong | |
InnerSpace CLLong | |
InnerSpace CFloat | |
InnerSpace CDouble | |
InnerSpace CIntMax | |
Integral a => InnerSpace (Ratio a) | |
(RealFloat v, InnerSpace v) => InnerSpace (Complex v) | |
InnerSpace a => InnerSpace (Maybe a) | |
InnerSpace v => InnerSpace (a -> v) | |
(InnerSpace u, ~ * s (Scalar u), InnerSpace v, ~ * s (Scalar v)) => InnerSpace (u, v) | |
(InnerSpace u, ~ * s (Scalar u), AdditiveGroup s, HasBasis a, HasTrie (Basis a)) => InnerSpace (:> a u) | |
(InnerSpace u, ~ * s (Scalar u), InnerSpace v, ~ * s (Scalar v), InnerSpace w, ~ * s (Scalar w)) => InnerSpace (u, v, w) | |
(InnerSpace u, ~ * s (Scalar u), InnerSpace v, ~ * s (Scalar v), InnerSpace w, ~ * s (Scalar w), InnerSpace x, ~ * s (Scalar x)) => InnerSpace (u, v, w, x) |
lerp :: VectorSpace v => v -> v -> Scalar v -> vSource
Linear interpolation between a
(when t==0
) and b
(when t==1
).
linearCombo :: VectorSpace v => [(v, Scalar v)] -> vSource
Linear combination of vectors
magnitudeSq :: (InnerSpace v, s ~ Scalar v) => v -> sSource
Square of the length of a vector. Sometimes useful for efficiency.
See also magnitude
.
magnitude :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> sSource
Length of a vector. See also magnitudeSq
.
normalized :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> vSource
Vector in same direction as given one but with length of one. If given the zero vector, then return it.
project :: (InnerSpace v, s ~ Scalar v, Fractional s) => v -> v -> vSource
project u v
computes the projection of v
onto u
.