linear-1.8.1: Linear Algebra

MaintainerEdward Kmett <>
Safe HaskellTrustworthy



Operations on affine spaces.



class Additive (Diff p) => Affine p whereSource

An affine space is roughly a vector space in which we have forgotten or at least pretend to have forgotten the origin.

 a .+^ (b .-. a)  =  b@
 (a .+^ u) .+^ v  =  a .+^ (u ^+^ v)@
 (a .-. b) ^+^ v  =  (a .+^ v) .-. q@

Associated Types

type Diff p :: * -> *Source


(.-.) :: Num a => p a -> p a -> Diff p aSource

Get the difference between two points as a vector offset.

(.+^) :: Num a => p a -> Diff p a -> p aSource

Add a vector offset to a point.

(.-^) :: Num a => p a -> Diff p a -> p aSource

Subtract a vector offset from a point.

qdA :: (Affine p, Foldable (Diff p), Num a) => p a -> p a -> aSource

Compute the quadrance of the difference (the square of the distance)

distanceA :: (Floating a, Foldable (Diff p), Affine p) => p a -> p a -> aSource

Distance between two points in an affine space

newtype Point f a Source

A handy wrapper to help distinguish points from vectors at the type level


P (f a) 


Monad f => Monad (Point f) 
Functor f => Functor (Point f) 
Applicative f => Applicative (Point f) 
Foldable f => Foldable (Point f) 
Traversable f => Traversable (Point f) 
Generic1 (Point f) 
Distributive f => Distributive (Point f) 
Representable f => Representable (Point f) 
Apply f => Apply (Point f) 
Bind f => Bind (Point f) 
Additive f => Additive (Point f) 
Metric f => Metric (Point f) 
R1 f => R1 (Point f) 
R2 f => R2 (Point f) 
R3 f => R3 (Point f) 
R4 f => R4 (Point f) 
Additive f => Affine (Point f) 
Eq (f a) => Eq (Point f a) 
Fractional (f a) => Fractional (Point f a) 
Num (f a) => Num (Point f a) 
Ord (f a) => Ord (Point f a) 
Read (f a) => Read (Point f a) 
Show (f a) => Show (Point f a) 
Ix (f a) => Ix (Point f a) 
Generic (Point f a) 
Storable (f a) => Storable (Point f a) 
Epsilon (f a) => Epsilon (Point f a) 

lensP :: Lens' (Point g a) (g a)Source

origin :: (Additive f, Num a) => Point f aSource

Vector spaces have origins.