Copyright | Copyright (c) 2009 Alexey Khudyakov <[email protected]> |
---|---|
License | BSD3 |
Maintainer | Alexey Khudyakov <[email protected]> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell98 |
Data.Histogram.ST
Contents
Description
Mutable histograms.
Synopsis
- data MHistogram s (v :: Type -> Type -> Type) bin a
- newMHistogram :: forall m bin (v :: Type -> Type -> Type) a. (PrimMonad m, Bin bin, MVector v a) => a -> bin -> m (MHistogram (PrimState m) v bin a)
- fill :: forall m (v :: Type -> Type -> Type) a bin b. (PrimMonad m, MVector v a, Bin bin) => MHistogram (PrimState m) v bin a -> BinValue bin -> (a -> b -> a) -> b -> m ()
- unsafeFreezeHist :: forall m (v :: Type -> Type) a bin. (PrimMonad m, Vector v a, Bin bin) => MHistogram (PrimState m) (Mutable v) bin a -> m (Histogram v bin a)
- freezeHist :: forall m (v :: Type -> Type) a bin. (PrimMonad m, Vector v a, Bin bin) => MHistogram (PrimState m) (Mutable v) bin a -> m (Histogram v bin a)
Mutable histograms
newMHistogram :: forall m bin (v :: Type -> Type -> Type) a. (PrimMonad m, Bin bin, MVector v a) => a -> bin -> m (MHistogram (PrimState m) v bin a) Source #
Create new mutable histogram. All bins are set to zero element as passed to function.
Arguments
:: forall m (v :: Type -> Type -> Type) a bin b. (PrimMonad m, MVector v a, Bin bin) | |
=> MHistogram (PrimState m) v bin a | Mutable histogram to put value to |
-> BinValue bin | Value being binned |
-> (a -> b -> a) | Fold function |
-> b | Value being put into histogram |
-> m () |
Generic fill. It could be seen as left fold with multiple
accumulators where accumulator is chosen by BinValue bin
.
unsafeFreezeHist :: forall m (v :: Type -> Type) a bin. (PrimMonad m, Vector v a, Bin bin) => MHistogram (PrimState m) (Mutable v) bin a -> m (Histogram v bin a) Source #
Create immutable histogram from mutable one. This operation is unsafe! Accumulator mustn't be used after that
freezeHist :: forall m (v :: Type -> Type) a bin. (PrimMonad m, Vector v a, Bin bin) => MHistogram (PrimState m) (Mutable v) bin a -> m (Histogram v bin a) Source #
Create immutable histogram from mutable one.