Safe Haskell | None |
---|
Data.Function.ArrayMemoize
- arrayMemo :: (Ix a, ArrayMemoizable b) => (a, a) -> (a -> b) -> a -> b
- arrayMemoFix :: (Ix a, ArrayMemoizable b) => (a, a) -> ((a -> b) -> a -> b) -> a -> b
- arrayMemoFixMutual :: (ArrayMemoizable b, ArrayMemoizable d, Ix a, Ix c) => (a, a) -> (c, c) -> ((a -> b) -> (c -> d) -> a -> b) -> ((a -> b) -> (c -> d) -> c -> d) -> a -> b
- arrayMemoFixMutual3 :: (ArrayMemoizable b, ArrayMemoizable d, ArrayMemoizable f, Ix a, Ix c, Ix e) => (a, a) -> (c, c) -> (e, e) -> ((a -> b) -> (c -> d) -> (e -> f) -> a -> b) -> ((a -> b) -> (c -> d) -> (e -> f) -> c -> d) -> ((a -> b) -> (c -> d) -> (e -> f) -> e -> f) -> a -> b
- uarrayMemoFixIO :: (Ix a, UArrayMemoizable b) => (a, a) -> ((a -> IO b) -> a -> IO b) -> a -> IO b
- discreteMemo :: (ArrayMemoizable b, Discretize a) => (a, a) -> a -> (a -> b) -> Discrete a -> b
- discreteMemoFix :: (ArrayMemoizable b, Discretize a) => (a, a) -> a -> ((a -> b) -> a -> b) -> Discrete a -> b
- quantizedMemo :: (ArrayMemoizable b, Discretize a) => (a, a) -> a -> (a -> b) -> a -> b
- quantizedMemoFix :: (ArrayMemoizable b, Discretize a) => (a, a) -> a -> ((a -> b) -> a -> b) -> a -> b
- quantizedMemoFixMutual :: (ArrayMemoizable b, ArrayMemoizable d, Discretize a, Discretize c) => (a, a) -> a -> (c, c) -> c -> ((a -> b) -> (c -> d) -> a -> b) -> ((a -> b) -> (c -> d) -> c -> d) -> a -> b
- quantizedMemoFixMutual3 :: (ArrayMemoizable b, ArrayMemoizable d, ArrayMemoizable f, Discretize a, Discretize c, Discretize e) => (a, a) -> a -> (c, c) -> c -> (e, e) -> e -> ((a -> b) -> (c -> d) -> (e -> f) -> a -> b) -> ((a -> b) -> (c -> d) -> (e -> f) -> c -> d) -> ((a -> b) -> (c -> d) -> (e -> f) -> e -> f) -> a -> b
- class ArrayMemoizable a where
- class IArray UArray a => UArrayMemoizable a where
- newUArray_ :: Ix i => (i, i) -> IO (IOUArray i a)
- writeUArray :: Ix i => IOUArray i a -> i -> a -> IO ()
- readUArray :: Ix i => IOUArray i a -> i -> IO a
- class (Ix (Discrete t), Enum (Discrete t)) => Discretize t where
- type Discrete t
- discretize :: t -> t -> Discrete t
- continuize :: t -> Discrete t -> t
- discrete :: Discretize a => (a -> b) -> a -> Discrete a -> b
Documentation
arrayMemo :: (Ix a, ArrayMemoizable b) => (a, a) -> (a -> b) -> a -> bSource
Memoize a function over a finite (sub)domain, using an array (boxed), e.g.,
arrayMemo (0, 20) f
memoizes f between from 0 to 20.
arrayMemoFix :: (Ix a, ArrayMemoizable b) => (a, a) -> ((a -> b) -> a -> b) -> a -> bSource
Memoize a fixed point of a function over a sub domain.
Similar to fix
, but over arrayMemo
, passing a function a memoized
version of itself.
arrayMemoFixMutual :: (ArrayMemoizable b, ArrayMemoizable d, Ix a, Ix c) => (a, a) -> (c, c) -> ((a -> b) -> (c -> d) -> a -> b) -> ((a -> b) -> (c -> d) -> c -> d) -> a -> bSource
Memoize a mutual fixed point for two functions (over sub domains of these functions).
arrayMemoFixMutual3 :: (ArrayMemoizable b, ArrayMemoizable d, ArrayMemoizable f, Ix a, Ix c, Ix e) => (a, a) -> (c, c) -> (e, e) -> ((a -> b) -> (c -> d) -> (e -> f) -> a -> b) -> ((a -> b) -> (c -> d) -> (e -> f) -> c -> d) -> ((a -> b) -> (c -> d) -> (e -> f) -> e -> f) -> a -> bSource
Memoize a mutual fixed point for three functions (over sub domains of these functions).
uarrayMemoFixIO :: (Ix a, UArrayMemoizable b) => (a, a) -> ((a -> IO b) -> a -> IO b) -> a -> IO bSource
discreteMemo :: (ArrayMemoizable b, Discretize a) => (a, a) -> a -> (a -> b) -> Discrete a -> bSource
Memoize and discretize a function over a finite (sub)domain, using an array. e.g.
discretemMemo (0.0, 10.0) 2.0 f
returns a discretized version of f (with the discrete type defined by Discrete
)
in the range 0.0 to 10.0 with step size 2.0 (i.e., the resulting discrete domain is
of size 5).
discreteMemoFix :: (ArrayMemoizable b, Discretize a) => (a, a) -> a -> ((a -> b) -> a -> b) -> Discrete a -> bSource
Memoize and discretize a fixed point of a function over a subdomain with discretization step
quantizedMemo :: (ArrayMemoizable b, Discretize a) => (a, a) -> a -> (a -> b) -> a -> bSource
Memoize and quantize a function over a finite (sub)domain, using a boxed array, e.g,
quantizedMemo (0.0, 10.0) 2.0 f
memoizes f between 0.0 and 10.0 with step size 2.0 (i.e. the function is quantized into
5 parts, memoized into an array of size 5).
quantizedMemoFix :: (ArrayMemoizable b, Discretize a) => (a, a) -> a -> ((a -> b) -> a -> b) -> a -> bSource
Memoize and quantize a fixed point of a function. Similar to fix
, but using quantizedMemo
to pass the fixed function a quantized memoized version of itself,
therefore memoizing any recursive calls.
quantizedMemoFixMutual :: (ArrayMemoizable b, ArrayMemoizable d, Discretize a, Discretize c) => (a, a) -> a -> (c, c) -> c -> ((a -> b) -> (c -> d) -> a -> b) -> ((a -> b) -> (c -> d) -> c -> d) -> a -> bSource
Memoize and quantize a mutually recursive fixed point of two functions.
quantizedMemoFixMutual3 :: (ArrayMemoizable b, ArrayMemoizable d, ArrayMemoizable f, Discretize a, Discretize c, Discretize e) => (a, a) -> a -> (c, c) -> c -> (e, e) -> e -> ((a -> b) -> (c -> d) -> (e -> f) -> a -> b) -> ((a -> b) -> (c -> d) -> (e -> f) -> c -> d) -> ((a -> b) -> (c -> d) -> (e -> f) -> e -> f) -> a -> bSource
Memoize and quantize a mutually recursive fixed point of three functions.
class ArrayMemoizable a whereSource
ArrayMemoizable
defines the subset of types for which we can do array
memoization
class IArray UArray a => UArrayMemoizable a whereSource
UArrayMemoizable
defines the subset of types for which we can
do unboxed IOUArray memoization
Methods
newUArray_ :: Ix i => (i, i) -> IO (IOUArray i a)Source
writeUArray :: Ix i => IOUArray i a -> i -> a -> IO ()Source
readUArray :: Ix i => IOUArray i a -> i -> IO aSource
class (Ix (Discrete t), Enum (Discrete t)) => Discretize t whereSource
Discretization of float/double values and tuples
Instances
Discretize Double | |
Discretize Float | |
(Discretize a, Discretize b) => Discretize (a, b) | |
(Discretize a, Discretize b, Discretize c) => Discretize (a, b, c) |
discrete :: Discretize a => (a -> b) -> a -> Discrete a -> bSource
Discretized a function function. The second parameter is the discretisation step.