Contents

Description

A continuous set of numbers.

Mathematics does not define a space, leaving library devs to experiment.

https://en.wikipedia.org/wiki/Space_(mathematics)

Synopsis

# Space

The final frontier.

class Space s where Source #

Space is a continuous range of numbers that contains elements and has an upper and lower value.

a union b == b union a
a intersection b == b intersection a
(a union b) intersection c == (a intersection b) union (a intersection c)
(a intersection b) union c == (a union b) intersection (a union c)
norm (norm a) = norm a
a |>| b == b |<| a
a |.| singleton a

Minimal complete definition

Associated Types

type Element s :: * Source #

the underlying element in the space

Methods

lower :: s -> Element s Source #

lower boundary

upper :: s -> Element s Source #

upper boundary

singleton :: Element s -> s Source #

space containing a single element

intersection :: s -> s -> s Source #

the intersection of two spaces

intersection :: Ord (Element s) => s -> s -> s Source #

the intersection of two spaces

union :: s -> s -> s Source #

the union of two spaces

union :: Ord (Element s) => s -> s -> s Source #

the union of two spaces

norm :: s -> s Source #

Normalise a space so that > lower a / upper a == lower a > lower a / upper a == upper a

(...) :: Element s -> Element s -> s infix 3 Source #

create a normalised space from two elements

(...) :: Ord (Element s) => Element s -> Element s -> s infix 3 Source #

create a normalised space from two elements

(>.<) :: Element s -> Element s -> s infix 3 Source #

create a space from two elements without normalising

(|.|) :: Element s -> s -> Bool infixl 7 Source #

is an element in the space

(|.|) :: Ord (Element s) => Element s -> s -> Bool infixl 7 Source #

is an element in the space

(|>|) :: s -> s -> Bool infixl 7 Source #

is one space completely above the other

(|>|) :: Ord (Element s) => s -> s -> Bool infixl 7 Source #

is one space completely above the other

(|<|) :: s -> s -> Bool infixl 7 Source #

is one space completely below the other

(|<|) :: Ord (Element s) => s -> s -> Bool infixl 7 Source #

is one space completely below the other

Instances
 (Eq a, Ord a) => Space (Range a) Source # Instance detailsDefined in NumHask.Space.Range Associated Typestype Element (Range a) :: Type Source # Methodslower :: Range a -> Element (Range a) Source #upper :: Range a -> Element (Range a) Source #singleton :: Element (Range a) -> Range a Source #intersection :: Range a -> Range a -> Range a Source #union :: Range a -> Range a -> Range a Source #norm :: Range a -> Range a Source #(...) :: Element (Range a) -> Element (Range a) -> Range a Source #(>.<) :: Element (Range a) -> Element (Range a) -> Range a Source #(|.|) :: Element (Range a) -> Range a -> Bool Source #(|>|) :: Range a -> Range a -> Bool Source #(|<|) :: Range a -> Range a -> Bool Source # Ord a => Space (Rect a) Source # Instance detailsDefined in NumHask.Space.Rect Associated Typestype Element (Rect a) :: Type Source # Methodslower :: Rect a -> Element (Rect a) Source #upper :: Rect a -> Element (Rect a) Source #singleton :: Element (Rect a) -> Rect a Source #intersection :: Rect a -> Rect a -> Rect a Source #union :: Rect a -> Rect a -> Rect a Source #norm :: Rect a -> Rect a Source #(...) :: Element (Rect a) -> Element (Rect a) -> Rect a Source #(>.<) :: Element (Rect a) -> Element (Rect a) -> Rect a Source #(|.|) :: Element (Rect a) -> Rect a -> Bool Source #(|>|) :: Rect a -> Rect a -> Bool Source #(|<|) :: Rect a -> Rect a -> Bool Source #

newtype Union a Source #

a convex hull

Constructors

 Union FieldsgetUnion :: a
Instances
 Space a => Semigroup (Union a) Source # Instance detailsDefined in NumHask.Space.Types Methods(<>) :: Union a -> Union a -> Union a #sconcat :: NonEmpty (Union a) -> Union a #stimes :: Integral b => b -> Union a -> Union a #

newtype Intersection a Source #

Constructors

 Intersection FieldsgetIntersection :: a
Instances
 Space a => Semigroup (Intersection a) Source # Instance detailsDefined in NumHask.Space.Types Methods(<>) :: Intersection a -> Intersection a -> Intersection a #stimes :: Integral b => b -> Intersection a -> Intersection a #

class (Space s, Num (Element s)) => FieldSpace s where Source #

a space that can be divided neatly

space1 (grid OuterPos s g) == s
getUnion (sconcat (Union <$> (gridSpace s g))) == s Associated Types type Grid s :: * Source # Methods grid :: Pos -> s -> Grid s -> [Element s] Source # create equally-spaced elements across a space gridSpace :: s -> Grid s -> [s] Source # create equally-spaced spaces from a space Instances  (Ord a, Fractional a) => FieldSpace (Range a) Source # Instance detailsDefined in NumHask.Space.Range Associated Typestype Grid (Range a) :: Type Source # Methodsgrid :: Pos -> Range a -> Grid (Range a) -> [Element (Range a)] Source #gridSpace :: Range a -> Grid (Range a) -> [Range a] Source # (Ord a, Fractional a, Num a) => FieldSpace (Rect a) Source # Instance detailsDefined in NumHask.Space.Rect Associated Typestype Grid (Rect a) :: Type Source # Methodsgrid :: Pos -> Rect a -> Grid (Rect a) -> [Element (Rect a)] Source #gridSpace :: Rect a -> Grid (Rect a) -> [Rect a] Source # mid :: (Space s, Fractional (Element s)) => s -> Element s Source # middle element of the space project :: (Space s, Fractional (Element s)) => s -> s -> Element s -> Element s Source # project a data point from one space to another, preserving relative position project o n (lower o) = lower n project o n (upper o) = upper n project a a x = x data Pos Source # Pos suggests where points should be placed in forming a grid across a field space. Constructors  OuterPos include boundaries InnerPos don't include boundaries LowerPos include the lower boundary UpperPos include the upper boundary MidPos use the mid-point of the space Instances  Source # Instance detailsDefined in NumHask.Space.Types Methods(==) :: Pos -> Pos -> Bool #(/=) :: Pos -> Pos -> Bool # Source # Instance detailsDefined in NumHask.Space.Types MethodsshowsPrec :: Int -> Pos -> ShowS #show :: Pos -> String #showList :: [Pos] -> ShowS # space1 :: (Space s, Traversable f) => f (Element s) -> s Source # the containing space of a non-empty Traversable > all$ space1 a contains \$ a

memberOf :: Space s => Element s -> s -> Bool Source #

is an element contained within a space

contains :: Space s => s -> s -> Bool Source #

is a space contained within another?

(a union b) contains a
(a union b) contains b

disjoint :: Space s => s -> s -> Bool Source #

are two spaces disjoint?

width :: (Space s, Num (Element s)) => s -> Element s Source #

distance between boundaries

(+/-) :: (Space s, Num (Element s)) => Element s -> Element s -> s infixl 6 Source #

create a space centered on a plus or minus b

monotone :: (Space a, Space b) => (Element a -> Element b) -> a -> b Source #

lift a monotone function (increasing or decreasing) over a given space

eps :: (Space s, Fractional (Element s)) => Element s -> Element s -> s Source #

a small space

widen :: (Space s, Num (Element s)) => Element s -> s -> s Source #

widen a space

widenEps :: (Space s, Fractional (Element s)) => Element s -> s -> s Source #

widen by a small amount

scale :: (Num (Element s), Space s) => Element s -> s -> s Source #

Scale a Space. (scalar multiplication)

move :: (Num (Element s), Space s) => Element s -> s -> s Source #