From 7633e42d95095e16ad459de6cd65b9f7e700136b Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Sat, 1 Jan 2011 19:25:58 +0000 Subject: examples/bool.hs --- lib/Numeric/ContainerBoot.hs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'lib/Numeric') diff --git a/lib/Numeric/ContainerBoot.hs b/lib/Numeric/ContainerBoot.hs index e33857a..276eaa8 100644 --- a/lib/Numeric/ContainerBoot.hs +++ b/lib/Numeric/ContainerBoot.hs @@ -121,14 +121,24 @@ class (Complexable c, Fractional e, Element e) => Container c e where sumElements :: c e -> e -- | the product of elements (faster than using @fold@) prodElements :: c e -> e - -- | map (if x_i>0 then 1.0 else 0.0) - step :: RealFloat e => c e -> c e + -- | a more efficient implementation of @cmap (\x -> if x>0 then 1 else 0)@ + step :: RealElement e => c e -> c e -- | find index of elements which satisfy a predicate find :: (e -> Bool) -> c e -> [IndexOf c] -- | create a structure from an association list - assoc :: IndexOf c -> e -> [(IndexOf c, e)] -> c e - -- | a vectorized form of case 'compare' a_i b_i of LT -> l_i; EQ -> e_i; GT -> g_i - cond :: RealFloat e => c e -> c e -> c e -> c e -> c e -> c e + assoc :: IndexOf c -- ^ size + -> e -- ^ default value + -> [(IndexOf c, e)] -- ^ association list + -> c e -- ^ result + + -- | element by element @case compare a b of LT -> l, EQ -> e, GT -> g@ + cond :: RealElement e + => c e -- ^ a + -> c e -- ^ b + -> c e -- ^ l + -> c e -- ^ e + -> c e -- ^ g + -> c e -- ^ result -------------------------------------------------------------------------- -- cgit v1.2.3