vector-space-0.10.2: 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.

Associated Types

type Scalar v :: * Source

Methods

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

Scale a vector

(^/) :: (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.

Methods

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

Inner/dot product

Instances

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 -> 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.