numhask-0.1.4.0: A numeric prelude

Safe HaskellSafe
LanguageHaskell2010

NumHask.Algebra.Metric

Description

Metric classes

Synopsis

Documentation

class MultiplicativeUnital a => Signed a where #

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 #

abs :: a -> a #

Instances

Signed Double # 

Methods

sign :: Double -> Double #

abs :: Double -> Double #

Signed Float # 

Methods

sign :: Float -> Float #

abs :: Float -> Float #

Signed Int # 

Methods

sign :: Int -> Int #

abs :: Int -> Int #

Signed Integer # 

Methods

sign :: Integer -> Integer #

abs :: Integer -> Integer #

class Normed a b where #

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

Minimal complete definition

size

Methods

size :: a -> b #

Instances

Normed Double Double # 

Methods

size :: Double -> Double #

Normed Float Float # 

Methods

size :: Float -> Float #

Normed Int Int # 

Methods

size :: Int -> Int #

Normed Integer Integer # 

Methods

size :: Integer -> Integer #

(Multiplicative a, ExpField a, Normed a a) => Normed (Complex a) a # 

Methods

size :: Complex a -> a #

class Metric a b where #

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 #

Instances

Metric Double Double # 

Methods

distance :: Double -> Double -> Double #

Metric Float Float # 

Methods

distance :: Float -> Float -> Float #

Metric Int Int # 

Methods

distance :: Int -> Int -> Int #

Metric Integer Integer # 

Methods

distance :: Integer -> Integer -> Integer #

(Multiplicative a, ExpField a, Normed a a) => Metric (Complex a) a # 

Methods

distance :: Complex a -> Complex a -> a #

class AdditiveGroup a => Epsilon a where #

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 #

aboutEqual :: a -> a -> Bool #

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

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

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

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

todo: is utf perfectly acceptable these days?