vector-space-0.5.1: Vector & affine spaces, linear maps, and derivatives (requires ghc 6.9)




Vector spaces

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



class AdditiveGroup v => VectorSpace v whereSource

Vector space v over a scalar field s. Extends AdditiveGroup with scalar multiplication.

Associated Types

type Scalar v :: *Source


(*^) :: Scalar v -> v -> vSource

Scale a vector


(^/) :: (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 => InnerSpace v whereSource

Adds inner (dot) products.


(<.>) :: v -> v -> Scalar vSource

Inner/dot product


lerp :: (VectorSpace v, s ~ Scalar v, Num s) => v -> v -> s -> vSource

Linear interpolation between a (when t==0) and b (when t==1).

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.