Copyright | (c) Artem Chirkin |
---|---|

License | BSD3 |

Safe Haskell | None |

Language | Haskell2010 |

## Synopsis

- class (ConcatList as bs asbs, Dimensions as, Dimensions bs, Dimensions asbs, PrimArray t (DataFrame t bs), PrimArray t (DataFrame t asbs), PrimBytes (DataFrame t bs), PrimBytes (DataFrame t asbs)) => SubSpace (t :: Type) (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) | asbs as -> bs, asbs bs -> as, as bs -> asbs where
- indexOffset# :: Int# -> DataFrame t asbs -> DataFrame t bs
- updateOffset# :: Int# -> DataFrame t bs -> DataFrame t asbs -> DataFrame t asbs
- index :: Idxs as -> DataFrame t asbs -> DataFrame t bs
- slice :: forall (bi :: Nat) (bd :: Nat) (b' :: Nat) (bs' :: [Nat]). (b' ~ ((bi + bd) - 1), bs ~ (b' :+ bs'), KnownDim bd) => Idxs (as +: bi) -> DataFrame t asbs -> DataFrame t (bd :+ bs')
- update :: Idxs as -> DataFrame t bs -> DataFrame t asbs -> DataFrame t asbs
- updateSlice :: forall (bi :: Nat) (bd :: Nat) (b' :: Nat) (bs' :: [Nat]). (b' ~ ((bi + bd) - 1), bs ~ (b' :+ bs'), KnownDim bd) => Idxs (as +: bi) -> DataFrame t (bd :+ bs') -> DataFrame t asbs -> DataFrame t asbs
- ewmap :: forall s (bs' :: [Nat]) (asbs' :: [Nat]). SubSpace s as bs' asbs' => (DataFrame s bs' -> DataFrame t bs) -> DataFrame s asbs' -> DataFrame t asbs
- iwmap :: forall s (bs' :: [Nat]) (asbs' :: [Nat]). SubSpace s as bs' asbs' => (Idxs as -> DataFrame s bs' -> DataFrame t bs) -> DataFrame s asbs' -> DataFrame t asbs
- ewgen :: DataFrame t bs -> DataFrame t asbs
- iwgen :: (Idxs as -> DataFrame t bs) -> DataFrame t asbs
- ewfoldl :: (b -> DataFrame t bs -> b) -> b -> DataFrame t asbs -> b
- iwfoldl :: (Idxs as -> b -> DataFrame t bs -> b) -> b -> DataFrame t asbs -> b
- ewfoldr :: (DataFrame t bs -> b -> b) -> b -> DataFrame t asbs -> b
- iwfoldr :: (Idxs as -> DataFrame t bs -> b -> b) -> b -> DataFrame t asbs -> b
- elementWise :: forall (s :: Type) (bs' :: [Nat]) (asbs' :: [Nat]) (f :: Type -> Type). (Applicative f, SubSpace s as bs' asbs') => (DataFrame s bs' -> f (DataFrame t bs)) -> DataFrame s asbs' -> f (DataFrame t asbs)
- indexWise :: forall (s :: Type) (bs' :: [Nat]) (asbs' :: [Nat]) (f :: Type -> Type). (Applicative f, SubSpace s as bs' asbs') => (Idxs as -> DataFrame s bs' -> f (DataFrame t bs)) -> DataFrame s asbs' -> f (DataFrame t asbs)

- (!) :: SubSpace t (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) => DataFrame t asbs -> Idxs as -> DataFrame t bs
- element :: forall t (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) f. (SubSpace t as bs asbs, Applicative f) => Idxs as -> (DataFrame t bs -> f (DataFrame t bs)) -> DataFrame t asbs -> f (DataFrame t asbs)
- ewfoldMap :: forall t (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) m. (Monoid m, SubSpace t as bs asbs) => (DataFrame t bs -> m) -> DataFrame t asbs -> m
- iwfoldMap :: forall t (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) m. (Monoid m, SubSpace t as bs asbs) => (Idxs as -> DataFrame t bs -> m) -> DataFrame t asbs -> m
- ewzip :: forall t (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) s (bs' :: [Nat]) (asbs' :: [Nat]) r (bs'' :: [Nat]) (asbs'' :: [Nat]). (SubSpace t as bs asbs, SubSpace s as bs' asbs', SubSpace r as bs'' asbs'') => (DataFrame t bs -> DataFrame s bs' -> DataFrame r bs'') -> DataFrame t asbs -> DataFrame s asbs' -> DataFrame r asbs''
- iwzip :: forall t (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) s (bs' :: [Nat]) (asbs' :: [Nat]) r (bs'' :: [Nat]) (asbs'' :: [Nat]). (SubSpace t as bs asbs, SubSpace s as bs' asbs', SubSpace r as bs'' asbs'') => (Idxs as -> DataFrame t bs -> DataFrame s bs' -> DataFrame r bs'') -> DataFrame t asbs -> DataFrame s asbs' -> DataFrame r asbs''
- indexWise_ :: forall t as bs asbs f b. (SubSpace t as bs asbs, Applicative f) => (Idxs as -> DataFrame t bs -> f b) -> DataFrame t asbs -> f ()
- elementWise_ :: forall t as bs asbs f b. (SubSpace t as bs asbs, Applicative f) => (DataFrame t bs -> f b) -> DataFrame t asbs -> f ()

# Documentation

class (ConcatList as bs asbs, Dimensions as, Dimensions bs, Dimensions asbs, PrimArray t (DataFrame t bs), PrimArray t (DataFrame t asbs), PrimBytes (DataFrame t bs), PrimBytes (DataFrame t asbs)) => SubSpace (t :: Type) (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) | asbs as -> bs, asbs bs -> as, as bs -> asbs where Source #

Operations on DataFrames

`as`

is an indexing dimensionality

`bs`

is an element dimensionality

`t`

is an underlying data type (i.e. Float, Int, Double)

Nothing

Unsafely get a sub-dataframe by its primitive element offset.
The offset is not checked to be aligned to the space structure or for bounds.
Arguments are zero-based primitive element offset and subset ("bs" element)
size (aka `totalDim`

of sub dataframe)

Normal indexing can be expressed in terms of `indexOffset#`

:

index i = case (# dimVal (dim @bs), fromEnum i #) of (# I# n, I# j #) -> indexOffset# (n *# j)

Unsafely update a sub-dataframe by its primitive element offset.
The offset is not checked to be aligned to the space structure or for bounds.
Arguments are zero-based primitive element offset and subset ("bs" element)
size (aka `totalDim`

of sub dataframe)

Normal updating can be expressed in terms of `indexOffset#`

:

update i = case (# dimVal (dim @bs), fromEnum i #) of (# I# n, I# j #) -> updateOffset# (n *# j)

index :: Idxs as -> DataFrame t asbs -> DataFrame t bs Source #

Get an element by its index in the dataframe

slice :: forall (bi :: Nat) (bd :: Nat) (b' :: Nat) (bs' :: [Nat]). (b' ~ ((bi + bd) - 1), bs ~ (b' :+ bs'), KnownDim bd) => Idxs (as +: bi) -> DataFrame t asbs -> DataFrame t (bd :+ bs') Source #

Get a few contiguous elements.

In a sense, this is just a more complicated version of `index`

.

update :: Idxs as -> DataFrame t bs -> DataFrame t asbs -> DataFrame t asbs Source #

Set a new value to an element

updateSlice :: forall (bi :: Nat) (bd :: Nat) (b' :: Nat) (bs' :: [Nat]). (b' ~ ((bi + bd) - 1), bs ~ (b' :+ bs'), KnownDim bd) => Idxs (as +: bi) -> DataFrame t (bd :+ bs') -> DataFrame t asbs -> DataFrame t asbs Source #

Update a few contiguous elements

In a sense, this is just a more complicated version of `update`

.

ewmap :: forall s (bs' :: [Nat]) (asbs' :: [Nat]). SubSpace s as bs' asbs' => (DataFrame s bs' -> DataFrame t bs) -> DataFrame s asbs' -> DataFrame t asbs Source #

Map a function over each element of DataFrame

iwmap :: forall s (bs' :: [Nat]) (asbs' :: [Nat]). SubSpace s as bs' asbs' => (Idxs as -> DataFrame s bs' -> DataFrame t bs) -> DataFrame s asbs' -> DataFrame t asbs Source #

Map a function over each element with its index of DataFrame

ewgen :: DataFrame t bs -> DataFrame t asbs Source #

Generate a DataFrame by repeating an element

iwgen :: (Idxs as -> DataFrame t bs) -> DataFrame t asbs Source #

Generate a DataFrame by iterating a function (index -> element)

ewfoldl :: (b -> DataFrame t bs -> b) -> b -> DataFrame t asbs -> b Source #

Left-associative fold of a DataFrame. The fold is strict, so accumulater is evaluated to WHNF; but you'd better make sure that the function is strict enough to not produce memory leaks deeply inside the result data type.

iwfoldl :: (Idxs as -> b -> DataFrame t bs -> b) -> b -> DataFrame t asbs -> b Source #

Left-associative fold of a DataFrame with an index The fold is strict, so accumulater is evaluated to WHNF; but you'd better make sure that the function is strict enough to not produce memory leaks deeply inside the result data type.

ewfoldr :: (DataFrame t bs -> b -> b) -> b -> DataFrame t asbs -> b Source #

Right-associative fold of a DataFrame The fold is strict, so accumulater is evaluated to WHNF; but you'd better make sure that the function is strict enough to not produce memory leaks deeply inside the result data type.

iwfoldr :: (Idxs as -> DataFrame t bs -> b -> b) -> b -> DataFrame t asbs -> b Source #

Right-associative fold of a DataFrame with an index The fold is strict, so accumulater is evaluated to WHNF; but you'd better make sure that the function is strict enough to not produce memory leaks deeply inside the result data type.

elementWise :: forall (s :: Type) (bs' :: [Nat]) (asbs' :: [Nat]) (f :: Type -> Type). (Applicative f, SubSpace s as bs' asbs') => (DataFrame s bs' -> f (DataFrame t bs)) -> DataFrame s asbs' -> f (DataFrame t asbs) Source #

Apply an applicative functor on each element (Lens-like traversal)

indexWise :: forall (s :: Type) (bs' :: [Nat]) (asbs' :: [Nat]) (f :: Type -> Type). (Applicative f, SubSpace s as bs' asbs') => (Idxs as -> DataFrame s bs' -> f (DataFrame t bs)) -> DataFrame s asbs' -> f (DataFrame t asbs) Source #

Apply an applicative functor on each element with its index (Lens-like indexed traversal)

## Instances

(ConcatList as bs asbs, Dimensions as, Dimensions bs, Dimensions asbs, PrimArray t (DataFrame t bs), PrimArray t (DataFrame t asbs), PrimBytes (DataFrame t bs), PrimBytes (DataFrame t asbs)) => SubSpace t as bs asbs Source # | |

Defined in Numeric.DataFrame.SubSpace indexOffset# :: Int# -> DataFrame t asbs -> DataFrame t bs Source # updateOffset# :: Int# -> DataFrame t bs -> DataFrame t asbs -> DataFrame t asbs Source # index :: Idxs as -> DataFrame t asbs -> DataFrame t bs Source # slice :: (b' ~ ((bi + bd) - 1), bs ~ (b' :+ bs'), KnownDim bd) => Idxs (as +: bi) -> DataFrame t asbs -> DataFrame t (bd :+ bs') Source # update :: Idxs as -> DataFrame t bs -> DataFrame t asbs -> DataFrame t asbs Source # updateSlice :: (b' ~ ((bi + bd) - 1), bs ~ (b' :+ bs'), KnownDim bd) => Idxs (as +: bi) -> DataFrame t (bd :+ bs') -> DataFrame t asbs -> DataFrame t asbs Source # ewmap :: SubSpace s as bs' asbs' => (DataFrame s bs' -> DataFrame t bs) -> DataFrame s asbs' -> DataFrame t asbs Source # iwmap :: SubSpace s as bs' asbs' => (Idxs as -> DataFrame s bs' -> DataFrame t bs) -> DataFrame s asbs' -> DataFrame t asbs Source # ewgen :: DataFrame t bs -> DataFrame t asbs Source # iwgen :: (Idxs as -> DataFrame t bs) -> DataFrame t asbs Source # ewfoldl :: (b -> DataFrame t bs -> b) -> b -> DataFrame t asbs -> b Source # iwfoldl :: (Idxs as -> b -> DataFrame t bs -> b) -> b -> DataFrame t asbs -> b Source # ewfoldr :: (DataFrame t bs -> b -> b) -> b -> DataFrame t asbs -> b Source # iwfoldr :: (Idxs as -> DataFrame t bs -> b -> b) -> b -> DataFrame t asbs -> b Source # elementWise :: (Applicative f, SubSpace s as bs' asbs') => (DataFrame s bs' -> f (DataFrame t bs)) -> DataFrame s asbs' -> f (DataFrame t asbs) Source # indexWise :: (Applicative f, SubSpace s as bs' asbs') => (Idxs as -> DataFrame s bs' -> f (DataFrame t bs)) -> DataFrame s asbs' -> f (DataFrame t asbs) Source # |

(!) :: SubSpace t (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) => DataFrame t asbs -> Idxs as -> DataFrame t bs infixl 4 Source #

Index an element (reverse arguments of `index`

)

element :: forall t (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) f. (SubSpace t as bs asbs, Applicative f) => Idxs as -> (DataFrame t bs -> f (DataFrame t bs)) -> DataFrame t asbs -> f (DataFrame t asbs) Source #

Apply a functor over a single element (simple lens)

ewfoldMap :: forall t (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) m. (Monoid m, SubSpace t as bs asbs) => (DataFrame t bs -> m) -> DataFrame t asbs -> m Source #

iwfoldMap :: forall t (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) m. (Monoid m, SubSpace t as bs asbs) => (Idxs as -> DataFrame t bs -> m) -> DataFrame t asbs -> m Source #

ewzip :: forall t (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) s (bs' :: [Nat]) (asbs' :: [Nat]) r (bs'' :: [Nat]) (asbs'' :: [Nat]). (SubSpace t as bs asbs, SubSpace s as bs' asbs', SubSpace r as bs'' asbs'') => (DataFrame t bs -> DataFrame s bs' -> DataFrame r bs'') -> DataFrame t asbs -> DataFrame s asbs' -> DataFrame r asbs'' Source #

Zip two spaces on a specified subspace element-wise (without index)

iwzip :: forall t (as :: [Nat]) (bs :: [Nat]) (asbs :: [Nat]) s (bs' :: [Nat]) (asbs' :: [Nat]) r (bs'' :: [Nat]) (asbs'' :: [Nat]). (SubSpace t as bs asbs, SubSpace s as bs' asbs', SubSpace r as bs'' asbs'') => (Idxs as -> DataFrame t bs -> DataFrame s bs' -> DataFrame r bs'') -> DataFrame t asbs -> DataFrame s asbs' -> DataFrame r asbs'' Source #

Zip two spaces on a specified subspace index-wise (with index)

indexWise_ :: forall t as bs asbs f b. (SubSpace t as bs asbs, Applicative f) => (Idxs as -> DataFrame t bs -> f b) -> DataFrame t asbs -> f () Source #

Apply an applicative functor on each element with its index (Lens-like indexed traversal)

elementWise_ :: forall t as bs asbs f b. (SubSpace t as bs asbs, Applicative f) => (DataFrame t bs -> f b) -> DataFrame t asbs -> f () Source #

Apply an applicative functor on each element (Lens-like traversal)