numhask-0.8.1.0: A numeric class hierarchy.
Safe HaskellNone
LanguageHaskell2010

NumHask.Algebra.Metric

Description

Metric classes

Synopsis

Documentation

class (Additive a, Multiplicative a) => Signed a where Source #

signum from base is not an operator name in numhask and is replaced by sign. Compare with Norm where there is a change in codomain.

abs a * sign a == a

abs zero == zero, so any value for sign zero is ok. We choose lawful neutral:

sign zero == zero

Methods

sign :: a -> a Source #

abs :: a -> a Source #

Instances

Instances details
Signed Double Source # 
Instance details

Defined in NumHask.Algebra.Metric

Signed Float Source # 
Instance details

Defined in NumHask.Algebra.Metric

Signed Int Source # 
Instance details

Defined in NumHask.Algebra.Metric

Methods

sign :: Int -> Int Source #

abs :: Int -> Int Source #

Signed Int8 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Methods

sign :: Int8 -> Int8 Source #

abs :: Int8 -> Int8 Source #

Signed Int16 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Signed Int32 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Signed Int64 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Signed Integer Source # 
Instance details

Defined in NumHask.Algebra.Metric

Signed Natural Source # 
Instance details

Defined in NumHask.Algebra.Metric

Signed Word Source # 
Instance details

Defined in NumHask.Algebra.Metric

Methods

sign :: Word -> Word Source #

abs :: Word -> Word Source #

Signed Word8 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Signed Word16 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Signed Word32 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Signed Word64 Source # 
Instance details

Defined in NumHask.Algebra.Metric

(Ord a, Signed a, Integral a, Ring a) => Signed (Ratio a) Source # 
Instance details

Defined in NumHask.Data.Rational

Methods

sign :: Ratio a -> Ratio a Source #

abs :: Ratio a -> Ratio a Source #

class (Additive a, Multiplicative b, Additive b) => Norm a b | a -> b where Source #

Norm is a slight generalisation of Signed. The class has the same shape but allows the codomain to be different to the domain.

norm a >= zero
norm zero == zero
a == norm a .* basis a
norm (basis a) == one

Methods

norm :: a -> b Source #

or length, or ||v||

basis :: a -> a Source #

or direction, or v-hat

Instances

Instances details
Norm Double Double Source # 
Instance details

Defined in NumHask.Algebra.Metric

Norm Float Float Source # 
Instance details

Defined in NumHask.Algebra.Metric

Norm Int Int Source # 
Instance details

Defined in NumHask.Algebra.Metric

Methods

norm :: Int -> Int Source #

basis :: Int -> Int Source #

Norm Int8 Int8 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Methods

norm :: Int8 -> Int8 Source #

basis :: Int8 -> Int8 Source #

Norm Int16 Int16 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Norm Int32 Int32 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Norm Int64 Int64 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Norm Integer Integer Source # 
Instance details

Defined in NumHask.Algebra.Metric

Norm Natural Natural Source # 
Instance details

Defined in NumHask.Algebra.Metric

Norm Word Word Source # 
Instance details

Defined in NumHask.Algebra.Metric

Methods

norm :: Word -> Word Source #

basis :: Word -> Word Source #

Norm Word8 Word8 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Norm Word16 Word16 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Norm Word32 Word32 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Norm Word64 Word64 Source # 
Instance details

Defined in NumHask.Algebra.Metric

ExpField a => Norm (Complex a) a Source #

A euclidean-style norm is strong convention for Complex.

Instance details

Defined in NumHask.Data.Complex

Methods

norm :: Complex a -> a Source #

basis :: Complex a -> Complex a Source #

(Ord a, Signed a, Integral a, Ring a) => Norm (Ratio a) (Ratio a) Source # 
Instance details

Defined in NumHask.Data.Rational

Methods

norm :: Ratio a -> Ratio a Source #

basis :: Ratio a -> Ratio a Source #

distance :: (Norm a b, Subtractive a) => a -> a -> b Source #

Distance, which combines the Subtractive notion of difference, with Norm.

distance a b >= zero
distance a a == zero
distance a b .* basis (a - b) == a - b

class (Additive coord, Multiplicative coord, Additive dir, Multiplicative dir) => Direction coord dir | coord -> dir where Source #

Convert between a "co-ordinated" or "higher-kinded" number and representations of an angle. Typically thought of as polar co-ordinate conversion.

See Polar coordinate system

ray . angle == basis
norm (ray x) == one

Methods

angle :: coord -> dir Source #

ray :: dir -> coord Source #

Instances

Instances details
TrigField a => Direction (Complex a) a Source # 
Instance details

Defined in NumHask.Data.Complex

Methods

angle :: Complex a -> a Source #

ray :: a -> Complex a Source #

data Polar mag dir Source #

Something that has a magnitude and a direction.

Constructors

Polar 

Fields

Instances

Instances details
(Eq mag, Eq dir) => Eq (Polar mag dir) Source # 
Instance details

Defined in NumHask.Algebra.Metric

Methods

(==) :: Polar mag dir -> Polar mag dir -> Bool #

(/=) :: Polar mag dir -> Polar mag dir -> Bool #

(Show mag, Show dir) => Show (Polar mag dir) Source # 
Instance details

Defined in NumHask.Algebra.Metric

Methods

showsPrec :: Int -> Polar mag dir -> ShowS #

show :: Polar mag dir -> String #

showList :: [Polar mag dir] -> ShowS #

Generic (Polar mag dir) Source # 
Instance details

Defined in NumHask.Algebra.Metric

Associated Types

type Rep (Polar mag dir) :: Type -> Type #

Methods

from :: Polar mag dir -> Rep (Polar mag dir) x #

to :: Rep (Polar mag dir) x -> Polar mag dir #

type Rep (Polar mag dir) Source # 
Instance details

Defined in NumHask.Algebra.Metric

type Rep (Polar mag dir) = D1 ('MetaData "Polar" "NumHask.Algebra.Metric" "numhask-0.8.1.0-6vtGETGPv6z5KBqA0pprnK" 'False) (C1 ('MetaCons "Polar" 'PrefixI 'True) (S1 ('MetaSel ('Just "magnitude") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 mag) :*: S1 ('MetaSel ('Just "direction") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 dir)))

polar :: (Norm coord mag, Direction coord dir) => coord -> Polar mag dir Source #

Convert from a number to a Polar.

coord :: (MultiplicativeAction coord mag, Direction coord dir) => Polar mag dir -> coord Source #

Convert from a Polar to a (coordinated aka higher-kinded) number.

class (Eq a, Additive a, Subtractive a, MeetSemiLattice a) => Epsilon a where Source #

A small number, especially useful for approximate equality.

Minimal complete definition

Nothing

Methods

epsilon :: a Source #

nearZero :: a -> Bool Source #

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

Instances

Instances details
Epsilon Double Source #

1e-14

Instance details

Defined in NumHask.Algebra.Metric

Epsilon Float Source #

1e-6

Instance details

Defined in NumHask.Algebra.Metric

Epsilon Int Source #

0

Instance details

Defined in NumHask.Algebra.Metric

Epsilon Int8 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Epsilon Int16 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Epsilon Int32 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Epsilon Int64 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Epsilon Integer Source # 
Instance details

Defined in NumHask.Algebra.Metric

Epsilon Word Source # 
Instance details

Defined in NumHask.Algebra.Metric

Epsilon Word8 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Epsilon Word16 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Epsilon Word32 Source # 
Instance details

Defined in NumHask.Algebra.Metric

Epsilon Word64 Source # 
Instance details

Defined in NumHask.Algebra.Metric

(Ord a, Signed a, Subtractive a, Epsilon a) => Epsilon (Complex a) Source # 
Instance details

Defined in NumHask.Data.Complex

(Ord a, Signed a, Integral a, Ring a, MeetSemiLattice a) => Epsilon (Ratio a) Source # 
Instance details

Defined in NumHask.Data.Rational

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

About equal.