linear-1.20.8: Linear Algebra

Linear.Metric

Description

Free metric spaces

Synopsis

Documentation

class Additive f => Metric f where #

Free and sparse inner product/metric spaces.

Minimal complete definition

Nothing

Methods

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

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 #

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 #

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

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

Compute the quadrance of the difference

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

Compute the distance between two vectors in a metric space

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

Compute the norm of a vector in a metric space

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

Convert a non-zero vector to unit vector.

Instances
 Metric [] # Instance detailsDefined in Linear.Metric Methodsdot :: Num a => [a] -> [a] -> a #quadrance :: Num a => [a] -> a #qd :: Num a => [a] -> [a] -> a #distance :: Floating a => [a] -> [a] -> a #norm :: Floating a => [a] -> a #signorm :: Floating a => [a] -> [a] # # Instance detailsDefined in Linear.Metric Methodsdot :: Num a => Maybe a -> Maybe a -> a #quadrance :: Num a => Maybe a -> a #qd :: Num a => Maybe a -> Maybe a -> a #distance :: Floating a => Maybe a -> Maybe a -> a #norm :: Floating a => Maybe a -> a #signorm :: Floating a => Maybe a -> Maybe a # # Instance detailsDefined in Linear.Metric Methodsdot :: Num a => ZipList a -> ZipList a -> a #quadrance :: Num a => ZipList a -> a #qd :: Num a => ZipList a -> ZipList a -> a #distance :: Floating a => ZipList a -> ZipList a -> a #norm :: Floating a => ZipList a -> a #signorm :: Floating a => ZipList a -> ZipList a # # Instance detailsDefined in Linear.Metric Methodsdot :: Num a => Identity a -> Identity a -> a #quadrance :: Num a => Identity a -> a #qd :: Num a => Identity a -> Identity a -> a #distance :: Floating a => Identity a -> Identity a -> a #norm :: Floating a => Identity a -> a #signorm :: Floating a => Identity a -> Identity a # # Instance detailsDefined in Linear.Metric Methodsdot :: Num a => IntMap a -> IntMap a -> a #quadrance :: Num a => IntMap a -> a #qd :: Num a => IntMap a -> IntMap a -> a #distance :: Floating a => IntMap a -> IntMap a -> a #norm :: Floating a => IntMap a -> a #signorm :: Floating a => IntMap a -> IntMap a # # Instance detailsDefined in Linear.Metric Methodsdot :: Num a => Vector a -> Vector a -> a #quadrance :: Num a => Vector a -> a #qd :: Num a => Vector a -> Vector a -> a #distance :: Floating a => Vector a -> Vector a -> a #norm :: Floating a => Vector a -> a #signorm :: Floating a => Vector a -> Vector a # # Instance detailsDefined in Linear.V1 Methodsdot :: Num a => V1 a -> V1 a -> a #quadrance :: Num a => V1 a -> a #qd :: Num a => V1 a -> V1 a -> a #distance :: Floating a => V1 a -> V1 a -> a #norm :: Floating a => V1 a -> a #signorm :: Floating a => V1 a -> V1 a # # Instance detailsDefined in Linear.V2 Methodsdot :: Num a => V2 a -> V2 a -> a #quadrance :: Num a => V2 a -> a #qd :: Num a => V2 a -> V2 a -> a #distance :: Floating a => V2 a -> V2 a -> a #norm :: Floating a => V2 a -> a #signorm :: Floating a => V2 a -> V2 a # # Instance detailsDefined in Linear.V3 Methodsdot :: Num a => V3 a -> V3 a -> a #quadrance :: Num a => V3 a -> a #qd :: Num a => V3 a -> V3 a -> a #distance :: Floating a => V3 a -> V3 a -> a #norm :: Floating a => V3 a -> a #signorm :: Floating a => V3 a -> V3 a # # Instance detailsDefined in Linear.V4 Methodsdot :: Num a => V4 a -> V4 a -> a #quadrance :: Num a => V4 a -> a #qd :: Num a => V4 a -> V4 a -> a #distance :: Floating a => V4 a -> V4 a -> a #norm :: Floating a => V4 a -> a #signorm :: Floating a => V4 a -> V4 a # # Instance detailsDefined in Linear.V0 Methodsdot :: Num a => V0 a -> V0 a -> a #quadrance :: Num a => V0 a -> a #qd :: Num a => V0 a -> V0 a -> a #distance :: Floating a => V0 a -> V0 a -> a #norm :: Floating a => V0 a -> a #signorm :: Floating a => V0 a -> V0 a # # Instance detailsDefined in Linear.Quaternion Methodsdot :: Num a => Quaternion a -> Quaternion a -> a #quadrance :: Num a => Quaternion a -> a #qd :: Num a => Quaternion a -> Quaternion a -> a #distance :: Floating a => Quaternion a -> Quaternion a -> a #norm :: Floating a => Quaternion a -> a #signorm :: Floating a => Quaternion a -> Quaternion a # # Instance detailsDefined in Linear.Plucker Methodsdot :: Num a => Plucker a -> Plucker a -> a #quadrance :: Num a => Plucker a -> a #qd :: Num a => Plucker a -> Plucker a -> a #distance :: Floating a => Plucker a -> Plucker a -> a #norm :: Floating a => Plucker a -> a #signorm :: Floating a => Plucker a -> Plucker a # Ord k => Metric (Map k) # Instance detailsDefined in Linear.Metric Methodsdot :: Num a => Map k a -> Map k a -> a #quadrance :: Num a => Map k a -> a #qd :: Num a => Map k a -> Map k a -> a #distance :: Floating a => Map k a -> Map k a -> a #norm :: Floating a => Map k a -> a #signorm :: Floating a => Map k a -> Map k a # (Hashable k, Eq k) => Metric (HashMap k) # Instance detailsDefined in Linear.Metric Methodsdot :: Num a => HashMap k a -> HashMap k a -> a #quadrance :: Num a => HashMap k a -> a #qd :: Num a => HashMap k a -> HashMap k a -> a #distance :: Floating a => HashMap k a -> HashMap k a -> a #norm :: Floating a => HashMap k a -> a #signorm :: Floating a => HashMap k a -> HashMap k a # Metric f => Metric (Point f) # Instance detailsDefined in Linear.Affine Methodsdot :: Num a => Point f a -> Point f a -> a #quadrance :: Num a => Point f a -> a #qd :: Num a => Point f a -> Point f a -> a #distance :: Floating a => Point f a -> Point f a -> a #norm :: Floating a => Point f a -> a #signorm :: Floating a => Point f a -> Point f a # Dim n => Metric (V n) # Instance detailsDefined in Linear.V Methodsdot :: Num a => V n a -> V n a -> a #quadrance :: Num a => V n a -> a #qd :: Num a => V n a -> V n a -> a #distance :: Floating a => V n a -> V n a -> a #norm :: Floating a => V n a -> a #signorm :: Floating a => V n a -> V n a #

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

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 #

project u v computes the projection of v onto u.