| Copyright | (c) Conal Elliott and Andy J Gill 2008 |
|---|---|
| License | BSD3 |
| Maintainer | conal@conal.net, andygill@ku.edu |
| Stability | experimental |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.VectorSpace
Description
Vector spaces
This version uses associated types instead of fundeps and requires ghc-6.10 or later
Synopsis
- 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 where Source #
Vector space v.
Minimal complete definition
Nothing
Instances
(^/) :: (VectorSpace v, s ~ Scalar v, Fractional s) => v -> s -> v infixr 7 Source #
Vector divided by scalar
class (VectorSpace v, AdditiveGroup (Scalar v)) => InnerSpace v where Source #
Adds inner (dot) products.
Minimal complete definition
Nothing
Instances
| InnerSpace CDouble Source # | |
| InnerSpace CFloat Source # | |
| InnerSpace CInt Source # | |
| InnerSpace CIntMax Source # | |
| InnerSpace CLLong Source # | |
| InnerSpace CLong Source # | |
| InnerSpace CSChar Source # | |
| InnerSpace CShort Source # | |
| InnerSpace Integer Source # | |
| InnerSpace Double Source # | |
| InnerSpace Float Source # | |
| InnerSpace Int Source # | |
| (RealFloat v, InnerSpace v) => InnerSpace (Complex v) Source # | |
| Integral a => InnerSpace (Ratio a) Source # | |
| InnerSpace a => InnerSpace (Maybe a) Source # | |
| (InnerSpace u, s ~ Scalar u, AdditiveGroup s, HasBasis a, HasTrie (Basis a)) => InnerSpace (a :> u) Source # | |
| (InnerSpace u, s ~ Scalar u, InnerSpace v, s ~ Scalar v) => InnerSpace (u, v) Source # | |
Defined in Data.VectorSpace | |
| InnerSpace v => InnerSpace (a -> v) Source # | |
Defined in Data.VectorSpace | |
| InnerSpace a => InnerSpace (Rec0 a s) Source # | |
| (InnerSpace u, s ~ Scalar u, InnerSpace v, s ~ Scalar v, InnerSpace w, s ~ Scalar w) => InnerSpace (u, v, w) Source # | |
Defined in Data.VectorSpace | |
| (InnerSpace (f p), InnerSpace (g p), Scalar (f p) ~ Scalar (g p), Num (Scalar (f p))) => InnerSpace ((f :*: g) p) Source # | |
| (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) Source # | |
Defined in Data.VectorSpace | |
| InnerSpace (f p) => InnerSpace (M1 i c f p) Source # | |
lerp :: VectorSpace v => v -> v -> Scalar v -> v Source #
Linear interpolation between a (when t==0) and b (when t==1).
linearCombo :: VectorSpace v => [(v, Scalar v)] -> v Source #
Linear combination of vectors
magnitudeSq :: (InnerSpace v, s ~ Scalar v) => v -> s Source #
Square of the length of a vector. Sometimes useful for efficiency.
See also magnitude.
magnitude :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> s Source #
Length of a vector. See also magnitudeSq.
normalized :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> v Source #
Vector in same direction as given one but with length of one. Divides by zero for the zero vector.
project :: (InnerSpace v, s ~ Scalar v, Fractional s) => v -> v -> v Source #
project u v computes the projection of v onto u.