linear-1.20.5: Linear Algebra

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

Linear.Metric

Description

Free metric spaces

Synopsis

Documentation

class Additive f => Metric f where Source #

Free and sparse inner product/metric spaces.

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

dot :: (Foldable f, 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

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

Metric [] Source # 

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 # 

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 Identity Source # 

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 ZipList Source # 

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 IntMap Source # 

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 # 

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 V0 Source # 

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 V1 Source # 

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 # 

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 # 

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 # 

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 Plucker Source # 

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 #

Metric Quaternion Source # 

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 #

Ord k => Metric (Map k) Source # 

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 # 

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 # 

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 k n => Metric (V k n) Source # 

Methods

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

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

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

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

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

signorm :: Floating a => V k n a -> V k n 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.