packages feed

repa 3.2.2.201204.1 → 3.2.3.1

raw patch · 6 files changed

+219/−28 lines, 6 filesdep ~QuickCheckdep ~basedep ~ghc-prim

Dependency ranges changed: QuickCheck, base, ghc-prim, template-haskell

Files

Data/Array/Repa.hs view
@@ -1,15 +1,8 @@ {-# OPTIONS -fno-warn-unused-imports #-}--- | ---   Legacy version for Haskell Platform 2012.04.------    * The Haskell Platform 2012.04 includes GHC 7.4 which does not work with the---      latest version of LLVM. ------    * You will get better performance if you upgrade to the most recent version of GHC.------   Repa arrays are wrappers around a linear structure that holds the element data. ------   The representation tag determines what structure holds the data.+-- | Repa arrays are wrappers around a linear structure that holds the element+--   data. +-- +--  The representation tag determines what structure holds the data. -- --   Delayed Representations (functions that compute elements) --@@ -200,6 +193,7 @@ import Data.Array.Repa.Operators.Interleave import Data.Array.Repa.Operators.Reduction import Data.Array.Repa.Operators.Selection+import Data.Array.Repa.Arbitrary                () import Prelude          ()  
+ Data/Array/Repa/Arbitrary.hs view
@@ -0,0 +1,123 @@+{-# LANGUAGE TypeOperators, FlexibleInstances, MultiParamTypeClasses, ScopedTypeVariables #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Data.Array.Repa.Arbitrary+        ( -- * Arbitrary Unboxed Arrays+          arbitraryUShaped+        , forAllUShaped+        , forAll2UShaped+        , forAll3UShaped+        , forAll4UShaped+        , forAll5UShaped++          -- * Arbitrary Boxed Arrays+        , arbitraryVShaped+        , forAllVShaped+        , forAll2VShaped+        , forAll3VShaped+        , forAll4VShaped+        , forAll5VShaped)+where+import Data.Array.Repa.Base+import Data.Array.Repa.Repr.Unboxed+import Data.Array.Repa.Shape+import Data.Array.Repa.Index+import Test.QuickCheck.Arbitrary+import Test.QuickCheck.Gen+import Test.QuickCheck.Property                 (forAll)+import Control.Monad+import qualified Data.Array.Repa.Repr.Vector    as V+import qualified Data.Vector.Unboxed            as U+++-- Aribrary -------------------------------------------------------------------+-- | This module exports instances of @Arbitrary@ and @CoArbitrary@ for+--   unboxed Repa arrays.+instance Arbitrary Z where+  arbitrary = return Z+++-- Note: this is a shape that is "sized", and then random array for a given+-- shape is generated.+instance (Shape a, Arbitrary a) => Arbitrary (a :. Int) where+ arbitrary +        = sized (\n -> do +                b       <- choose (1, n)+                let dimLimit :: Int = ceiling (fromIntegral n / fromIntegral b :: Double)+                a       <- resize dimLimit arbitrary+                -- each dimension should be at least 1-wide+                return $ a :. b)+++-- | Generates a random unboxed array of a given shape+arbitraryUShaped sh =   fromListUnboxed sh `fmap` vector (size sh)+++-- | Generates a random boxed array of a given shape+arbitraryVShaped sh = V.fromListVector  sh `fmap` vector (size sh)+++instance (Arbitrary sh, Arbitrary a, U.Unbox a, Shape sh) +       => Arbitrary (Array U sh a) where+  arbitrary = arbitrary >>= arbitraryUShaped+++instance (Arbitrary sh, Arbitrary a, Shape sh) +       => Arbitrary (Array V.V sh a) where+  arbitrary = arbitrary >>= arbitraryVShaped+++-- CoArbitrary ----------------------------------------------------------------+instance CoArbitrary Z where+  coarbitrary _ = id ++instance (Shape a, CoArbitrary a) +       => CoArbitrary (a :. Int) where+  coarbitrary (a :. b) = coarbitrary a >< coarbitrary b++instance (CoArbitrary sh, CoArbitrary a, Source r a, Shape sh) +       => CoArbitrary (Array r sh a) where+  coarbitrary arr +        = (coarbitrary . extent $ arr) >< (coarbitrary . toList $ arr)+++-- Wrappers -------------------------------------------------------------------+-- | Convenience functions for writing tests on 2-,3-,4-tuples of arrays+--   of the same size (or just of a fixed size.)++-- | These are helper functions:+forAll2 arbf = forAll $ liftM2 (,)    arbf arbf+forAll3 arbf = forAll $ liftM3 (,,)   arbf arbf arbf+forAll4 arbf = forAll $ liftM4 (,,,)  arbf arbf arbf arbf+forAll5 arbf = forAll $ liftM5 (,,,,) arbf arbf arbf arbf arbf+++-- | Property tested for unboxed random arrays with a given shape.+forAllUShaped sh  = forAll  $ arbitraryUShaped sh++-- | Property tested for pair of unboxed random arrays with a given shape.+forAll2UShaped sh = forAll2 $ arbitraryUShaped sh++-- | Property tested for triple of unboxed random arrays with a given shape.+forAll3UShaped sh = forAll3 $ arbitraryUShaped sh++-- | Property tested for quadruple of unboxed random arrays with a given shape.+forAll4UShaped sh = forAll4 $ arbitraryUShaped sh++-- | Property tested for 5-tuple of unboxed random arrays with a given shape.+forAll5UShaped sh = forAll5 $ arbitraryUShaped sh+++-- | Property tested for unboxed random arrays with a given shape.+forAllVShaped sh  = forAll  $ arbitraryVShaped sh++-- | Property tested for pair of unboxed random arrays with a given shape.+forAll2VShaped sh = forAll2 $ arbitraryVShaped sh++-- | Property tested for triple of unboxed random arrays with a given shape.+forAll3VShaped sh = forAll3 $ arbitraryVShaped sh++-- | Property tested for quadruple of unboxed random arrays with a given shape.+forAll4VShaped sh = forAll4 $ arbitraryVShaped sh++-- | Property tested for 5-tuple of unboxed random arrays with a given shape.+forAll5VShaped sh = forAll5 $ arbitraryVShaped sh
Data/Array/Repa/Eval/Elt.hs view
@@ -1,5 +1,6 @@ -- | Values that can be stored in Repa Arrays. {-# LANGUAGE MagicHash, UnboxedTuples, TypeSynonymInstances, FlexibleInstances #-}+{-# LANGUAGE DefaultSignatures, FlexibleContexts, TypeOperators #-} module Data.Array.Repa.Eval.Elt 	(Elt (..)) where@@ -8,13 +9,14 @@ import GHC.Types import GHC.Word import GHC.Int+import GHC.Generics   -- Note that the touch# function is special because we can pass it boxed or unboxed -- values. The argument type has kind ?, not just * or #.  -- | Element types that can be used with the blockwise filling functions.---  +-- --   This class is mainly used to define the `touch` method. This is used internally --   in the imeplementation of Repa to prevent let-binding from being floated --   inappropriately by the GHC simplifier.  Doing a `seq` sometimes isn't enough,@@ -22,15 +24,89 @@ -- class Elt a where -	-- | Place a demand on a value at a particular point in an IO computation.-	touch :: a -> IO ()+        -- | Place a demand on a value at a particular point in an IO computation.+        touch :: a -> IO () -	-- | Generic zero value, helpful for debugging.-	zero  :: a+        default touch :: (Generic a, GElt (Rep a)) => a -> IO ()+        touch = gtouch . from+        {-# INLINE touch #-} -	-- | Generic one value, helpful for debugging.-	one   :: a+        -- | Generic zero value, helpful for debugging.+        zero  :: a +        default zero :: (Generic a, GElt (Rep a)) => a+        zero = to gzero+        {-# INLINE zero #-}++        -- | Generic one value, helpful for debugging.+        one   :: a++        default one :: (Generic a, GElt (Rep a)) => a+        one = to gone+        {-# INLINE one #-}++class GElt f where+        -- | Generic version of touch+        gtouch :: f a -> IO ()++        -- | Generic version of zero+        gzero  :: f a++        -- | Generic version of gone+        gone   :: f a++-- Generic Definition ----------------------------------------------------------++instance GElt U1 where+  gtouch _ = return ()+  {-# INLINE gtouch #-}++  gzero = U1+  {-# INLINE gzero #-}++  gone = U1+  {-# INLINE gone #-}++instance (GElt a, GElt b) => GElt (a :*: b) where+  gtouch (x :*: y) = gtouch x >> gtouch y+  {-# INLINE gtouch #-}++  gzero = gzero :*: gzero+  {-# INLINE gzero #-}++  gone = gone :*: gone+  {-# INLINE gone #-}++instance (GElt a, GElt b) => GElt (a :+: b) where+  gtouch (L1 x) = gtouch x+  gtouch (R1 x) = gtouch x+  {-# INLINE gtouch #-}++  gzero = L1 gzero+  {-# INLINE gzero #-}++  gone = R1 gone+  {-# INLINE gone #-}++instance (GElt a) => GElt (M1 i c a) where+  gtouch (M1 x) = gtouch x+  {-# INLINE gtouch #-}++  gzero = M1 gzero+  {-# INLINE gzero #-}++  gone = M1 gone+  {-# INLINE gone #-}++instance (Elt a) => GElt (K1 i a) where+  gtouch (K1 x) = touch x+  {-# INLINE gtouch #-}++  gzero = K1 zero+  {-# INLINE gzero #-}++  gone = K1 one+  {-# INLINE gone #-}  -- Bool ----------------------------------------------------------------------- instance Elt Bool where
Data/Array/Repa/Eval/Gang.hs view
@@ -100,7 +100,7 @@         -- Add finalisers so we can shut the workers down cleanly if they         -- become unreachable.         zipWithM_ (\varReq varDone -                        -> addMVarFinalizer varReq (finaliseWorker varReq varDone)) +                        -> mkWeakMVar varReq (finaliseWorker varReq varDone))                  mvsRequest                 mvsDone 
Data/Array/Repa/Stencil/Template.hs view
@@ -92,7 +92,7 @@ 	 $ AppE (VarE (mkName "makeStencil2")                          `AppE` (LitE (IntegerL sizeX))                          `AppE` (LitE (IntegerL sizeY)))-         $ LetE [ PragmaD (InlineP (mkName "coeffs") (InlineSpec True False Nothing))+         $ LetE [ PragmaD (InlineP (mkName "coeffs") Inline FunLike (BeforePhase 0)) 		, ValD 	  (VarP    coeffs')          (NormalB fnCoeffs) [] ] 		(VarE (mkName "coeffs")) 
repa.cabal view
@@ -1,5 +1,5 @@ Name:                repa-Version:             3.2.2.201204.1+Version:             3.2.3.1 License:             BSD3 License-file:        LICENSE Author:              The DPH Team@@ -11,9 +11,6 @@ Homepage:            http://repa.ouroborus.net Bug-reports:         repa@ouroborus.net Description:-        Legacy version for Haskell Platform 2012.04. You will get better performance-        if you upgrade to the most recent version of GHC.-         Repa provides high performance, regular, multi-dimensional, shape polymorphic         parallel arrays. All numeric data is stored unboxed. Functions written with         the Repa combinators are automatically parallel provided you supply@@ -24,12 +21,12 @@  Library   Build-Depends: -        base                 == 4.5.*,-        ghc-prim             == 0.2.*,+        base                 == 4.6.*,+        ghc-prim             == 0.3.*,         vector               == 0.10.*,         bytestring           == 0.10.*,-        template-haskell     == 2.7.*,-        QuickCheck           == 2.4.*+        template-haskell     == 2.8.*,+        QuickCheck           >= 2.3 && < 2.6    ghc-options:         -Wall -fno-warn-missing-signatures@@ -70,6 +67,7 @@         Data.Array.Repa.Repr.Vector         Data.Array.Repa.Specialised.Dim2         Data.Array.Repa.Stencil.Dim2+        Data.Array.Repa.Arbitrary         Data.Array.Repa.Eval         Data.Array.Repa.Index         Data.Array.Repa.Shape