numhask-0.2.0.0: numeric classes

Safe HaskellSafe
LanguageHaskell2010

NumHask.Algebra.Metric

Description

Metric classes

Synopsis

Documentation

class MultiplicativeUnital a => Signed a where Source #

signum from base is not an operator replicated in numhask, being such a very silly name, and preferred is the much more obvious sign. Compare with Norm and Banach where there is a change in codomain

abs a * sign a == a

Generalising this class tends towards size and direction (abs is the size on the one-dim number line of a vector with its tail at zero, and sign is the direction, right?).

Minimal complete definition

sign, abs

Methods

sign :: a -> a Source #

abs :: a -> a Source #

class Normed a b where Source #

Like Signed, except the codomain can be different to the domain.

Minimal complete definition

size

Methods

size :: a -> b Source #

class Metric a b where Source #

distance between numbers

distance a b >= zero
distance a a == zero
\a b c -> distance a c + distance b c - distance a b >= zero &&
          distance a b + distance b c - distance a c >= zero &&
          distance a b + distance a c - distance b c >= zero &&

Minimal complete definition

distance

Methods

distance :: a -> a -> b Source #

class AdditiveGroup a => Epsilon a where Source #

todo: This should probably be split off into some sort of alternative Equality logic, but to what end?

Minimal complete definition

nearZero, aboutEqual

Methods

nearZero :: a -> Bool Source #

aboutEqual :: a -> a -> Bool Source #

positive :: (Eq a, Signed a) => a -> Bool Source #

veryPositive :: (Eq a, Signed a) => a -> Bool Source #

veryNegative :: (Eq a, Signed a) => a -> Bool Source #

(≈) :: Epsilon a => a -> a -> Bool infixl 4 Source #

todo: is utf perfectly acceptable these days?