vector-space-0.10.4: Vector & affine spaces, linear maps, and derivatives

Copyright(c) Conal Elliott and Andy J Gill 2008
LicenseBSD3
Maintainerconal@conal.net, andygill@ku.edu
Stabilityexperimental
Safe HaskellNone
LanguageHaskell98

Data.VectorSpace

Description

Vector spaces

This version uses associated types instead of fundeps and requires ghc-6.10 or later

Synopsis

Documentation

class AdditiveGroup v => VectorSpace v where Source #

Vector space v.

Minimal complete definition

(*^)

Associated Types

type Scalar v :: * Source #

Methods

(*^) :: Scalar v -> v -> v infixr 7 Source #

Scale a vector

Instances

VectorSpace Double Source # 

Associated Types

type Scalar Double :: * Source #

VectorSpace Float Source # 

Associated Types

type Scalar Float :: * Source #

Methods

(*^) :: Scalar Float -> Float -> Float Source #

VectorSpace Int Source # 

Associated Types

type Scalar Int :: * Source #

Methods

(*^) :: Scalar Int -> Int -> Int Source #

VectorSpace Integer Source # 

Associated Types

type Scalar Integer :: * Source #

VectorSpace CSChar Source # 

Associated Types

type Scalar CSChar :: * Source #

VectorSpace CShort Source # 

Associated Types

type Scalar CShort :: * Source #

VectorSpace CInt Source # 

Associated Types

type Scalar CInt :: * Source #

Methods

(*^) :: Scalar CInt -> CInt -> CInt Source #

VectorSpace CLong Source # 

Associated Types

type Scalar CLong :: * Source #

Methods

(*^) :: Scalar CLong -> CLong -> CLong Source #

VectorSpace CLLong Source # 

Associated Types

type Scalar CLLong :: * Source #

VectorSpace CFloat Source # 

Associated Types

type Scalar CFloat :: * Source #

VectorSpace CDouble Source # 

Associated Types

type Scalar CDouble :: * Source #

VectorSpace CIntMax Source # 

Associated Types

type Scalar CIntMax :: * Source #

VectorSpace v => VectorSpace (Maybe v) Source # 

Associated Types

type Scalar (Maybe v) :: * Source #

Methods

(*^) :: Scalar (Maybe v) -> Maybe v -> Maybe v Source #

Integral a => VectorSpace (Ratio a) Source # 

Associated Types

type Scalar (Ratio a) :: * Source #

Methods

(*^) :: Scalar (Ratio a) -> Ratio a -> Ratio a Source #

(RealFloat v, VectorSpace v) => VectorSpace (Complex v) Source # 

Associated Types

type Scalar (Complex v) :: * Source #

Methods

(*^) :: Scalar (Complex v) -> Complex v -> Complex v Source #

VectorSpace v => VectorSpace (a -> v) Source # 

Associated Types

type Scalar (a -> v) :: * Source #

Methods

(*^) :: Scalar (a -> v) -> (a -> v) -> a -> v Source #

(VectorSpace u, (~) * s (Scalar u), VectorSpace v, (~) * s (Scalar v)) => VectorSpace (u, v) Source # 

Associated Types

type Scalar (u, v) :: * Source #

Methods

(*^) :: Scalar (u, v) -> (u, v) -> (u, v) Source #

(HasTrie a, VectorSpace v) => VectorSpace ((:->:) a v) Source # 

Associated Types

type Scalar ((:->:) a v) :: * Source #

Methods

(*^) :: Scalar (a :->: v) -> (a :->: v) -> a :->: v Source #

(HasTrie (Basis u), VectorSpace v) => VectorSpace ((:-*) u v) Source # 

Associated Types

type Scalar ((:-*) u v) :: * Source #

Methods

(*^) :: Scalar (u :-* v) -> (u :-* v) -> u :-* v Source #

(HasBasis a, HasTrie (Basis a), VectorSpace u) => VectorSpace ((:>) a u) Source # 

Associated Types

type Scalar ((:>) a u) :: * Source #

Methods

(*^) :: Scalar (a :> u) -> (a :> u) -> a :> u Source #

(VectorSpace u, (~) * s (Scalar u), VectorSpace v, (~) * s (Scalar v), VectorSpace w, (~) * s (Scalar w)) => VectorSpace (u, v, w) Source # 

Associated Types

type Scalar (u, v, w) :: * Source #

Methods

(*^) :: Scalar (u, v, w) -> (u, v, w) -> (u, v, w) Source #

(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) Source # 

Associated Types

type Scalar (u, v, w, x) :: * Source #

Methods

(*^) :: Scalar (u, v, w, x) -> (u, v, w, x) -> (u, v, w, x) Source #

(^/) :: (VectorSpace v, s ~ Scalar v, Fractional s) => v -> s -> v infixr 7 Source #

Vector divided by scalar

(^*) :: (VectorSpace v, s ~ Scalar v) => v -> s -> v infixl 7 Source #

Vector multiplied by scalar

class (VectorSpace v, AdditiveGroup (Scalar v)) => InnerSpace v where Source #

Adds inner (dot) products.

Minimal complete definition

(<.>)

Methods

(<.>) :: v -> v -> Scalar v infixr 7 Source #

Inner/dot product

Instances

InnerSpace Double Source # 
InnerSpace Float Source # 

Methods

(<.>) :: Float -> Float -> Scalar Float Source #

InnerSpace Int Source # 

Methods

(<.>) :: Int -> Int -> Scalar Int Source #

InnerSpace Integer Source # 
InnerSpace CSChar Source # 
InnerSpace CShort Source # 
InnerSpace CInt Source # 

Methods

(<.>) :: CInt -> CInt -> Scalar CInt Source #

InnerSpace CLong Source # 

Methods

(<.>) :: CLong -> CLong -> Scalar CLong Source #

InnerSpace CLLong Source # 
InnerSpace CFloat Source # 
InnerSpace CDouble Source # 
InnerSpace CIntMax Source # 
InnerSpace a => InnerSpace (Maybe a) Source # 

Methods

(<.>) :: Maybe a -> Maybe a -> Scalar (Maybe a) Source #

Integral a => InnerSpace (Ratio a) Source # 

Methods

(<.>) :: Ratio a -> Ratio a -> Scalar (Ratio a) Source #

(RealFloat v, InnerSpace v) => InnerSpace (Complex v) Source # 

Methods

(<.>) :: Complex v -> Complex v -> Scalar (Complex v) Source #

InnerSpace v => InnerSpace (a -> v) Source # 

Methods

(<.>) :: (a -> v) -> (a -> v) -> Scalar (a -> v) Source #

(InnerSpace u, (~) * s (Scalar u), InnerSpace v, (~) * s (Scalar v)) => InnerSpace (u, v) Source # 

Methods

(<.>) :: (u, v) -> (u, v) -> Scalar (u, v) Source #

(InnerSpace u, (~) * s (Scalar u), AdditiveGroup s, HasBasis a, HasTrie (Basis a)) => InnerSpace ((:>) a u) Source # 

Methods

(<.>) :: (a :> u) -> (a :> u) -> Scalar (a :> u) Source #

(InnerSpace u, (~) * s (Scalar u), InnerSpace v, (~) * s (Scalar v), InnerSpace w, (~) * s (Scalar w)) => InnerSpace (u, v, w) Source # 

Methods

(<.>) :: (u, v, w) -> (u, v, w) -> Scalar (u, v, w) 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 # 

Methods

(<.>) :: (u, v, w, x) -> (u, v, w, x) -> Scalar (u, v, w, x) 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. If given the zero vector, then return it.

project :: (InnerSpace v, s ~ Scalar v, Fractional s) => v -> v -> v Source #

project u v computes the projection of v onto u.