linear-1.20.8: Linear Algebra

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 # Instance detailsDefined in Linear.Metric Methodsdot :: 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 # Source # Instance detailsDefined in Linear.Metric Methodsdot :: 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 # Source # Instance detailsDefined in Linear.Metric Methodsdot :: 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 # Source # Instance detailsDefined in Linear.Metric Methodsdot :: 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 # Source # Instance detailsDefined in Linear.Metric Methodsdot :: 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 # Source # Instance detailsDefined in Linear.Metric Methodsdot :: 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 # Source # Instance detailsDefined in Linear.V1 Methodsdot :: 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 # Source # Instance detailsDefined in Linear.V2 Methodsdot :: 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 # Source # Instance detailsDefined in Linear.V3 Methodsdot :: 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 # Source # Instance detailsDefined in Linear.V4 Methodsdot :: 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 # Source # Instance detailsDefined in Linear.V0 Methodsdot :: 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 # Source # Instance detailsDefined in Linear.Quaternion Methodsdot :: 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 # Source # Instance detailsDefined in Linear.Plucker Methodsdot :: 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 detailsDefined in Linear.Metric Methodsdot :: 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 detailsDefined in Linear.Metric Methodsdot :: 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 detailsDefined in Linear.Affine Methodsdot :: 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 detailsDefined in Linear.V Methodsdot :: 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 #

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.