linear-1.21.8: Linear Algebra
Copyright(C) 2012-2015 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellTrustworthy
LanguageHaskell2010

Linear.Metric

Description

Free metric spaces

Synopsis

Documentation

class Additive f => Metric f where Source #

Free and sparse inner product/metric spaces.

Minimal complete definition

Nothing

Methods

dot :: Num a => f a -> f a -> a Source #

Compute the inner product of two vectors or (equivalently) convert a vector f a into a covector f a -> a.

>>> V2 1 2 `dot` V2 3 4
11

default dot :: (Foldable f, Num a) => f a -> f a -> a Source #

quadrance :: Num a => f a -> a Source #

Compute the squared norm. The name quadrance arises from Norman J. Wildberger's rational trigonometry.

qd :: Num a => f a -> f a -> a Source #

Compute the quadrance of the difference

distance :: Floating a => f a -> f a -> a Source #

Compute the distance between two vectors in a metric space

norm :: Floating a => f a -> a Source #

Compute the norm of a vector in a metric space

signorm :: Floating a => f a -> f a Source #

Convert a non-zero vector to unit vector.

Instances

Instances details
Metric [] Source # 
Instance details

Defined in Linear.Metric

Methods

dot :: Num a => [a] -> [a] -> a Source #

quadrance :: Num a => [a] -> a Source #

qd :: Num a => [a] -> [a] -> a Source #

distance :: Floating a => [a] -> [a] -> a Source #

norm :: Floating a => [a] -> a Source #

signorm :: Floating a => [a] -> [a] Source #

Metric Maybe Source # 
Instance details

Defined in Linear.Metric

Methods

dot :: Num a => Maybe a -> Maybe a -> a Source #

quadrance :: Num a => Maybe a -> a Source #

qd :: Num a => Maybe a -> Maybe a -> a Source #

distance :: Floating a => Maybe a -> Maybe a -> a Source #

norm :: Floating a => Maybe a -> a Source #

signorm :: Floating a => Maybe a -> Maybe a Source #

Metric ZipList Source # 
Instance details

Defined in Linear.Metric

Methods

dot :: Num a => ZipList a -> ZipList a -> a Source #

quadrance :: Num a => ZipList a -> a Source #

qd :: Num a => ZipList a -> ZipList a -> a Source #

distance :: Floating a => ZipList a -> ZipList a -> a Source #

norm :: Floating a => ZipList a -> a Source #

signorm :: Floating a => ZipList a -> ZipList a Source #

Metric Identity Source # 
Instance details

Defined in Linear.Metric

Methods

dot :: Num a => Identity a -> Identity a -> a Source #

quadrance :: Num a => Identity a -> a Source #

qd :: Num a => Identity a -> Identity a -> a Source #

distance :: Floating a => Identity a -> Identity a -> a Source #

norm :: Floating a => Identity a -> a Source #

signorm :: Floating a => Identity a -> Identity a Source #

Metric IntMap Source # 
Instance details

Defined in Linear.Metric

Methods

dot :: Num a => IntMap a -> IntMap a -> a Source #

quadrance :: Num a => IntMap a -> a Source #

qd :: Num a => IntMap a -> IntMap a -> a Source #

distance :: Floating a => IntMap a -> IntMap a -> a Source #

norm :: Floating a => IntMap a -> a Source #

signorm :: Floating a => IntMap a -> IntMap a Source #

Metric Vector Source # 
Instance details

Defined in Linear.Metric

Methods

dot :: Num a => Vector a -> Vector a -> a Source #

quadrance :: Num a => Vector a -> a Source #

qd :: Num a => Vector a -> Vector a -> a Source #

distance :: Floating a => Vector a -> Vector a -> a Source #

norm :: Floating a => Vector a -> a Source #

signorm :: Floating a => Vector a -> Vector a Source #

Metric V1 Source # 
Instance details

Defined in Linear.V1

Methods

dot :: Num a => V1 a -> V1 a -> a Source #

quadrance :: Num a => V1 a -> a Source #

qd :: Num a => V1 a -> V1 a -> a Source #

distance :: Floating a => V1 a -> V1 a -> a Source #

norm :: Floating a => V1 a -> a Source #

signorm :: Floating a => V1 a -> V1 a Source #

Metric V2 Source # 
Instance details

Defined in Linear.V2

Methods

dot :: Num a => V2 a -> V2 a -> a Source #

quadrance :: Num a => V2 a -> a Source #

qd :: Num a => V2 a -> V2 a -> a Source #

distance :: Floating a => V2 a -> V2 a -> a Source #

norm :: Floating a => V2 a -> a Source #

signorm :: Floating a => V2 a -> V2 a Source #

Metric V3 Source # 
Instance details

Defined in Linear.V3

Methods

dot :: Num a => V3 a -> V3 a -> a Source #

quadrance :: Num a => V3 a -> a Source #

qd :: Num a => V3 a -> V3 a -> a Source #

distance :: Floating a => V3 a -> V3 a -> a Source #

norm :: Floating a => V3 a -> a Source #

signorm :: Floating a => V3 a -> V3 a Source #

Metric V4 Source # 
Instance details

Defined in Linear.V4

Methods

dot :: Num a => V4 a -> V4 a -> a Source #

quadrance :: Num a => V4 a -> a Source #

qd :: Num a => V4 a -> V4 a -> a Source #

distance :: Floating a => V4 a -> V4 a -> a Source #

norm :: Floating a => V4 a -> a Source #

signorm :: Floating a => V4 a -> V4 a Source #

Metric V0 Source # 
Instance details

Defined in Linear.V0

Methods

dot :: Num a => V0 a -> V0 a -> a Source #

quadrance :: Num a => V0 a -> a Source #

qd :: Num a => V0 a -> V0 a -> a Source #

distance :: Floating a => V0 a -> V0 a -> a Source #

norm :: Floating a => V0 a -> a Source #

signorm :: Floating a => V0 a -> V0 a Source #

Metric Quaternion Source # 
Instance details

Defined in Linear.Quaternion

Methods

dot :: Num a => Quaternion a -> Quaternion a -> a Source #

quadrance :: Num a => Quaternion a -> a Source #

qd :: Num a => Quaternion a -> Quaternion a -> a Source #

distance :: Floating a => Quaternion a -> Quaternion a -> a Source #

norm :: Floating a => Quaternion a -> a Source #

signorm :: Floating a => Quaternion a -> Quaternion a Source #

Metric Plucker Source # 
Instance details

Defined in Linear.Plucker

Methods

dot :: Num a => Plucker a -> Plucker a -> a Source #

quadrance :: Num a => Plucker a -> a Source #

qd :: Num a => Plucker a -> Plucker a -> a Source #

distance :: Floating a => Plucker a -> Plucker a -> a Source #

norm :: Floating a => Plucker a -> a Source #

signorm :: Floating a => Plucker a -> Plucker a Source #

Ord k => Metric (Map k) Source # 
Instance details

Defined in Linear.Metric

Methods

dot :: Num a => Map k a -> Map k a -> a Source #

quadrance :: Num a => Map k a -> a Source #

qd :: Num a => Map k a -> Map k a -> a Source #

distance :: Floating a => Map k a -> Map k a -> a Source #

norm :: Floating a => Map k a -> a Source #

signorm :: Floating a => Map k a -> Map k a Source #

(Hashable k, Eq k) => Metric (HashMap k) Source # 
Instance details

Defined in Linear.Metric

Methods

dot :: Num a => HashMap k a -> HashMap k a -> a Source #

quadrance :: Num a => HashMap k a -> a Source #

qd :: Num a => HashMap k a -> HashMap k a -> a Source #

distance :: Floating a => HashMap k a -> HashMap k a -> a Source #

norm :: Floating a => HashMap k a -> a Source #

signorm :: Floating a => HashMap k a -> HashMap k a Source #

Metric f => Metric (Point f) Source # 
Instance details

Defined in Linear.Affine

Methods

dot :: Num a => Point f a -> Point f a -> a Source #

quadrance :: Num a => Point f a -> a Source #

qd :: Num a => Point f a -> Point f a -> a Source #

distance :: Floating a => Point f a -> Point f a -> a Source #

norm :: Floating a => Point f a -> a Source #

signorm :: Floating a => Point f a -> Point f a Source #

Dim n => Metric (V n) Source # 
Instance details

Defined in Linear.V

Methods

dot :: Num a => V n a -> V n a -> a Source #

quadrance :: Num a => V n a -> a Source #

qd :: Num a => V n a -> V n a -> a Source #

distance :: Floating a => V n a -> V n a -> a Source #

norm :: Floating a => V n a -> a Source #

signorm :: Floating a => V n a -> V n a Source #

(Metric f, Metric g) => Metric (Product f g) Source # 
Instance details

Defined in Linear.Metric

Methods

dot :: Num a => Product f g a -> Product f g a -> a Source #

quadrance :: Num a => Product f g a -> a Source #

qd :: Num a => Product f g a -> Product f g a -> a Source #

distance :: Floating a => Product f g a -> Product f g a -> a Source #

norm :: Floating a => Product f g a -> a Source #

signorm :: Floating a => Product f g a -> Product f g a Source #

(Metric f, Metric g) => Metric (Compose f g) Source # 
Instance details

Defined in Linear.Metric

Methods

dot :: Num a => Compose f g a -> Compose f g a -> a Source #

quadrance :: Num a => Compose f g a -> a Source #

qd :: Num a => Compose f g a -> Compose f g a -> a Source #

distance :: Floating a => Compose f g a -> Compose f g a -> a Source #

norm :: Floating a => Compose f g a -> a Source #

signorm :: Floating a => Compose f g a -> Compose f g a Source #

normalize :: (Floating a, Metric f, Epsilon a) => f a -> f a Source #

Normalize a Metric functor to have unit norm. This function does not change the functor if its norm is 0 or 1.

project :: (Metric v, Fractional a) => v a -> v a -> v a Source #

project u v computes the projection of v onto u.