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

Stabilityexperimental
Maintainerconal@conal.net, andygill@ku.edu

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

Vector space v.

Associated Types

type Scalar v :: *

Methods

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

Scale a vector

Instances

(^/) :: (VectorSpace v, s ~ Scalar v, Fractional s) => v -> s -> v

Vector divided by scalar

(^*) :: (VectorSpace v, s ~ Scalar v) => v -> s -> v

Vector multiplied by scalar

class VectorSpace v => InnerSpace v where

Adds inner (dot) products.

Methods

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

Inner/dot product

Instances

lerp :: VectorSpace v => v -> v -> Scalar v -> v

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

magnitudeSq :: (InnerSpace v, s ~ Scalar v) => v -> s

Square of the length of a vector. Sometimes useful for efficiency. See also magnitude.

magnitude :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> s

Length of a vector. See also magnitudeSq.

normalized :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> v

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, Floating s) => v -> v -> v

project u v computes the projection of v onto u.