linear-accelerate-0.4: Lifting linear vector spaces into Accelerate

Copyright2014 Edward Kmett Charles Durham
2015 Trevor L. McDonell
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell98

Data.Array.Accelerate.Linear.Metric

Description

Free metric spaces

Synopsis

Documentation

>>> import Data.Array.Accelerate.Linear.V2 ()
>>> import Linear.V2

class Metric f => Metric f where Source #

Free and sparse inner product/metric spaces.

Methods

dot :: forall a. (Num a, Box f a) => Exp (f a) -> Exp (f a) -> Exp a Source #

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

>>> lift (V2 1 2 :: V2 Int) `dot` lift (V2 3 4 :: V2 Int)
11

quadrance :: forall a. (Num a, Box f a) => Exp (f a) -> Exp a Source #

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

qd :: forall a. (Num a, Box f a) => Exp (f a) -> Exp (f a) -> Exp a Source #

Compute the quadrance of the difference

distance :: forall a. (Floating a, Box f a) => Exp (f a) -> Exp (f a) -> Exp a Source #

Compute the distance between two vectors in a metric space

norm :: forall a. (Floating a, Box f a) => Exp (f a) -> Exp a Source #

Compute the norm of a vector in a metric space

signorm :: forall a. (Floating a, Box f a) => Exp (f a) -> Exp (f a) Source #

Convert a non-zero vector to unit vector.

type IsMetric f a = (Metric f, Box f a) Source #

normalize :: (Elt (f a), Floating a, IsMetric f a, Epsilon a) => Exp (f a) -> Exp (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 :: forall f a. (Floating a, IsMetric f a) => Exp (f a) -> Exp (f a) -> Exp (f a) Source #

project u v computes the projection of v onto u.