Description

A Space containing numerical elements

Synopsis

# Documentation

data Range a Source #

A continuous range over type a

>>> let a = Range (-1) 1
>>> a
Range -1 1


Num instance based on interval arithmetic (with Ranges normalising to lower ... upper)

>>> a + a
Range -2 2
>>> a * a
Range -1 1
>>> (+1) <$> (Range 1 2) Range 2 3  Ranges are very useful in shifting a bunch of numbers from one Range to another. eg project 0.5 from the range 0 to 1 to the range 1 to 4 >>> project (Range 0 1) (Range 1 4) 0.5 2.5  Create an equally spaced grid including outer bounds over a Range >>> grid OuterPos (Range 0 10) 5 [0.0,2.0,4.0,6.0,8.0,10.0]  divide up a Range into equal-sized sections >>> gridSpace (Range 0 1) 4 [Range 0.0 0.25,Range 0.25 0.5,Range 0.5 0.75,Range 0.75 1.0]  Constructors  Range a a Instances  Source # Instance detailsDefined in NumHask.Space.Range Methodsfmap :: (a -> b) -> Range a -> Range b #(<$) :: a -> Range b -> Range a # Source # Instance detailsDefined in NumHask.Space.Range Methodspure :: a -> Range a #(<*>) :: Range (a -> b) -> Range a -> Range b #liftA2 :: (a -> b -> c) -> Range a -> Range b -> Range c #(*>) :: Range a -> Range b -> Range b #(<*) :: Range a -> Range b -> Range a # Source # Instance detailsDefined in NumHask.Space.Range Methodsfold :: Monoid m => Range m -> m #foldMap :: Monoid m => (a -> m) -> Range a -> m #foldr :: (a -> b -> b) -> b -> Range a -> b #foldr' :: (a -> b -> b) -> b -> Range a -> b #foldl :: (b -> a -> b) -> b -> Range a -> b #foldl' :: (b -> a -> b) -> b -> Range a -> b #foldr1 :: (a -> a -> a) -> Range a -> a #foldl1 :: (a -> a -> a) -> Range a -> a #toList :: Range a -> [a] #null :: Range a -> Bool #length :: Range a -> Int #elem :: Eq a => a -> Range a -> Bool #maximum :: Ord a => Range a -> a #minimum :: Ord a => Range a -> a #sum :: Num a => Range a -> a #product :: Num a => Range a -> a # Source # Instance detailsDefined in NumHask.Space.Range Methodstraverse :: Applicative f => (a -> f b) -> Range a -> f (Range b) #sequenceA :: Applicative f => Range (f a) -> f (Range a) #mapM :: Monad m => (a -> m b) -> Range a -> m (Range b) #sequence :: Monad m => Range (m a) -> m (Range a) # Source # Instance detailsDefined in NumHask.Space.Range Methodsdistribute :: Functor f => f (Range a) -> Range (f a) #collect :: Functor f => (a -> Range b) -> f a -> Range (f b) #distributeM :: Monad m => m (Range a) -> Range (m a) #collectM :: Monad m => (a -> Range b) -> m a -> Range (m b) # Source # Instance detailsDefined in NumHask.Space.Range Associated Typestype Rep Range :: Type # Methodstabulate :: (Rep Range -> a) -> Range a #index :: Range a -> Rep Range -> a # Source # Instance detailsDefined in NumHask.Space.Range MethodsliftEq :: (a -> b -> Bool) -> Range a -> Range b -> Bool # Source # Instance detailsDefined in NumHask.Space.Range MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Range a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Range a] -> ShowS # Source # Instance detailsDefined in NumHask.Space.Range Methods(<.>) :: Range (a -> b) -> Range a -> Range b #(.>) :: Range a -> Range b -> Range b #(<.) :: Range a -> Range b -> Range a #liftF2 :: (a -> b -> c) -> Range a -> Range b -> Range c # Source # Instance detailsDefined in NumHask.Space.Range Methodsfold1 :: Semigroup m => Range m -> m #foldMap1 :: Semigroup m => (a -> m) -> Range a -> m #toNonEmpty :: Range a -> NonEmpty a # Source # Instance detailsDefined in NumHask.Space.Range Methodstraverse1 :: Apply f => (a -> f b) -> Range a -> f (Range b) #sequence1 :: Apply f => Range (f b) -> f (Range b) # Eq a => Eq (Range a) Source # Instance detailsDefined in NumHask.Space.Range Methods(==) :: Range a -> Range a -> Bool #(/=) :: Range a -> Range a -> Bool # (Num a, Eq a, Ord a) => Num (Range a) Source # Numeric algebra based on Interval arithmetic Instance detailsDefined in NumHask.Space.Range Methods(+) :: Range a -> Range a -> Range a #(-) :: Range a -> Range a -> Range a #(*) :: Range a -> Range a -> Range a #negate :: Range a -> Range a #abs :: Range a -> Range a #signum :: Range a -> Range a # Show a => Show (Range a) Source # Instance detailsDefined in NumHask.Space.Range MethodsshowsPrec :: Int -> Range a -> ShowS #show :: Range a -> String #showList :: [Range a] -> ShowS # Generic (Range a) Source # Instance detailsDefined in NumHask.Space.Range Associated Typestype Rep (Range a) :: Type -> Type # Methodsfrom :: Range a -> Rep (Range a) x #to :: Rep (Range a) x -> Range a # (Eq a, Ord a) => Semigroup (Range a) Source # Monoid based on convex hull union Instance detailsDefined in NumHask.Space.Range Methods(<>) :: Range a -> Range a -> Range a #sconcat :: NonEmpty (Range a) -> Range a #stimes :: Integral b => b -> Range a -> Range a # Ord a => Lattice (Range a) Source # Instance detailsDefined in NumHask.Space.Range Methods(\/) :: Range a -> Range a -> Range a #(/\) :: Range a -> Range a -> Range a # (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 # (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 # type Rep Range Source # Instance detailsDefined in NumHask.Space.Range type Rep Range = Bool type Rep (Range a) Source # Instance detailsDefined in NumHask.Space.Range type Rep (Range a) = D1 (MetaData "Range" "NumHask.Space.Range" "numhask-space-0.3.0-GM7MUIaWR8l8Uregq0MgYU" False) (C1 (MetaCons "Range" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))) type Grid (Range a) Source # Instance detailsDefined in NumHask.Space.Range type Grid (Range a) = Int type Element (Range a) Source # Instance detailsDefined in NumHask.Space.Range type Element (Range a) = a

gridSensible :: (Ord a, RealFrac a, Floating a, Integral b) => Pos -> Bool -> Range a -> b -> [a] Source #

a grid with human sensible (rounded) values

>>> gridSensible OuterPos False (Range (-12.0) 23.0) 6
[-15.0,-10.0,-5.0,0.0,5.0,10.0,15.0,20.0,25.0]