packages feed

accelerate-random (empty) → 0.15.0.0

raw patch · 4 files changed

+157/−0 lines, 4 filesdep +acceleratedep +basedep +mwc-randomsetup-changed

Dependencies added: accelerate, base, mwc-random

Files

+ Data/Array/Accelerate/System/Random/MWC.hs view
@@ -0,0 +1,88 @@+{-# LANGUAGE RankNTypes    #-}+{-# LANGUAGE TypeOperators #-}+-- Module:      : Data.Array.Accelerate.System.Random.MWC+-- Copyright    : [2014..2015] Trevor L. McDonell+-- License      : BSD3+--+-- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>+-- Stability    : experimental+-- Portability  : non-portable (GHC extensions)+--++module Data.Array.Accelerate.System.Random.MWC (++  -- * Generating random arrays+  (:~>),+  uniform, uniformR,+  randomArray, randomArrayWith,++  -- * Re-export MWC-Random+  module System.Random.MWC,++) where++import System.Random.MWC                        hiding ( uniform, uniformR )+import qualified System.Random.MWC              as R++import Data.Array.Accelerate                    as A+import Data.Array.Accelerate.Array.Data         as A+import Data.Array.Accelerate.Array.Sugar        as Sugar+++-- | A PRNG from indices to variates+--+type sh :~> e = sh -> GenIO -> IO e+++-- | Uniformly distributed random variates.+--+uniform :: (Shape sh, Elt e, Variate e) => sh :~> e+uniform _ = R.uniform++-- | Uniformly distributed random variates in a given range.+--+uniformR :: (Shape sh, Elt e, Variate e) => (e, e) -> sh :~> e+uniformR bounds _ = R.uniformR bounds+++-- | Generate an array of random values. The generator for variates is+-- initialised with a fixed seed.+--+randomArray :: (Shape sh, Elt e) => sh :~> e -> sh -> IO (Array sh e)+randomArray f sh+  = do+      gen <- create+      randomArrayWith gen f sh+++-- | Generate an array of random values using the supplied generator.+--+randomArrayWith+    :: (Shape sh, Elt e)+    => GenIO+    -> sh :~> e+    -> sh+    -> IO (Array sh e)+randomArrayWith gen f sh+  = do+      adata  <- runRandomArray f sh gen+      return $! Array (fromElt sh) adata+++-- Create a mutable array and fill it with random values+--+runRandomArray+    :: (Shape sh, Elt e)+    => sh :~> e+    -> sh+    -> GenIO+    -> IO (MutableArrayData (EltRepr e))+runRandomArray f sh gen+  = do+      arr <- newArrayData $! Sugar.size sh+      let write ix = unsafeWriteArrayData arr (Sugar.toIndex sh ix)+                   . fromElt =<< f ix gen+      --+      iter sh write (>>) (return ())+      return arr+
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2015, Trevor L. McDonell++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Trevor L. McDonell nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ accelerate-random.cabal view
@@ -0,0 +1,37 @@+name:                  accelerate-random+version:               0.15.0.0+synopsis:              Generate Accelerate arrays filled with high quality pseudorandom numbers+description:+  Generate /Accelerate/ arrays filled with high-quality pseudorandom numbers.+  .+  Refer to the main /Accelerate/ package for more information:+  <http://hackage.haskell.org/package/accelerate>+  .+tested-with:            GHC >= 7.8++license:               BSD3+license-file:          LICENSE+author:                Trevor L. McDonell+maintainer:            Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>+-- copyright:+category:              Data+build-type:            Simple+-- extra-source-files:+cabal-version:         >=1.10++library+  default-language:    Haskell2010+  exposed-modules:+    Data.Array.Accelerate.System.Random.MWC++  build-depends:+      base                      >= 4.7 && < 4.9+    , accelerate                == 0.15.*+    , mwc-random                >= 0.8++Source-repository this+  type:                 git+  location:             git://github.com/tmcdonell/accelerate-random.git+  branch:               release/0.15+  tag:                  0.15.0.0+