Safe Haskell | None |
---|---|
Language | Haskell2010 |
A continuous set of numbers.
Mathematics does not define a space, leaving library devs to experiment.
Synopsis
- class Space s where
- type Element s :: Type
- lower :: s -> Element s
- upper :: s -> Element s
- singleton :: Element s -> s
- intersection :: s -> s -> s
- union :: s -> s -> s
- norm :: s -> s
- (...) :: Element s -> Element s -> s
- (>.<) :: Element s -> Element s -> s
- (|.|) :: Element s -> s -> Bool
- (|>|) :: s -> s -> Bool
- (|<|) :: s -> s -> Bool
- newtype Union a = Union {
- getUnion :: a
- newtype Intersection a = Intersection {
- getIntersection :: a
- class (Space s, Field (Element s)) => FieldSpace s where
- mid :: (Space s, Field (Element s)) => s -> Element s
- project :: (Space s, Field (Element s)) => s -> s -> Element s -> Element s
- data Pos
- space1 :: (Space s, Traversable f) => f (Element s) -> s
- memberOf :: Space s => Element s -> s -> Bool
- contains :: Space s => s -> s -> Bool
- disjoint :: Space s => s -> s -> Bool
- width :: (Space s, Subtractive (Element s)) => s -> Element s
- (+/-) :: (Space s, Subtractive (Element s)) => Element s -> Element s -> s
- monotone :: (Space a, Space b) => (Element a -> Element b) -> a -> b
- eps :: (Space s, FromRational (Element s), Field (Element s)) => Element s -> Element s -> s
- widen :: (Space s, Ring (Element s)) => Element s -> s -> s
- widenEps :: (Space s, FromRational (Element s), Field (Element s)) => Element s -> s -> s
- scale :: (Multiplicative (Element s), Space s) => Element s -> s -> s
- move :: (Additive (Element s), Space s) => Element s -> s -> s
- module NumHask.Space.Point
- module NumHask.Space.Range
- module NumHask.Space.Rect
- module NumHask.Space.Time
- module NumHask.Space.Histogram
- module NumHask.Space.XY
Space
The final frontier.
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
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
the union of two spaces
union :: Ord (Element s) => s -> s -> s Source #
the union of two spaces
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
a convex hull
newtype Intersection a Source #
Instances
Space a => Semigroup (Intersection a) Source # | |
Defined in NumHask.Space.Types (<>) :: Intersection a -> Intersection a -> Intersection a # sconcat :: NonEmpty (Intersection a) -> Intersection a # stimes :: Integral b => b -> Intersection a -> Intersection a # |
class (Space s, Field (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
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
FieldSpace (Range Double) Source # | |
FieldSpace (Rect Double) Source # | |
project :: (Space s, Field (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 o n (mid o) = mid n project a a x = x
Pos suggests where points should be placed in forming a grid across a field space.
space1 :: (Space s, Traversable f) => f (Element s) -> s Source #
the containing space of a non-empty Traversable
all $ space1 a `contains` <$> a
contains :: Space s => s -> s -> Bool Source #
is a space contained within another?
(a `union` b) `contains` a (a `union` b) `contains` b
(+/-) :: (Space s, Subtractive (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, FromRational (Element s), Field (Element s)) => Element s -> Element s -> s Source #
a small space
widenEps :: (Space s, FromRational (Element s), Field (Element s)) => Element s -> s -> s Source #
widen by a small amount
scale :: (Multiplicative (Element s), Space s) => Element s -> s -> s Source #
Scale a Space. (scalar multiplication)
move :: (Additive (Element s), Space s) => Element s -> s -> s Source #
Move a Space. (scalar addition)
Instances
Space is an interesting cross-section of many programming domains.
- A Range is a Space of numbers.
- A Rect is a Space of Points.
- A time span is a space containing moments of time.
- A histogram is a divided Range with a count of elements within each division.
module NumHask.Space.Point
module NumHask.Space.Range
module NumHask.Space.Rect
module NumHask.Space.Time
module NumHask.Space.Histogram
module NumHask.Space.XY