packages feed

repa-examples 3.1.0.1 → 3.1.3.1

raw patch · 7 files changed

+38/−46 lines, 7 filesdep ~base

Dependency ranges changed: base

Files

examples/Blur/src-repa/Main.hs view
@@ -73,8 +73,7 @@  = go iterations arrInit  where  go !0 !arr = return arr         go !n !arr  - 	 = arr `deepSeqArray` -           do   arr'    <- computeP+ 	 = do   arr'    <- computeP                          $ A.cmap (/ 159)                          $ forStencil2 BoundClamp arr                            [stencil2|   2  4  5  4  2
examples/Canny/src-repa/Main.hs view
@@ -32,13 +32,11 @@ type Image a	= Array U DIM2 a  -- Constants --------------------------------------------------------------------- TODO: It would be better to use Word8 to represent the edge orientations,---       but doing so currently triggers a bug in the LLVM mangler.-orientUndef	= 0	:: Int-orientPosDiag	= 64	:: Int-orientVert	= 128	:: Int-orientNegDiag	= 192	:: Int-orientHoriz	= 255	:: Int+orientUndef	= 0	:: Word8+orientPosDiag	= 64	:: Word8+orientVert	= 128	:: Word8+orientNegDiag	= 192	:: Word8+orientHoriz	= 255	:: Word8  data Edge	= None | Weak | Strong edge None	= 0 	:: Word8@@ -144,7 +142,7 @@ -- | RGB to greyscale conversion. toGreyScale :: Monad m => Image (Word8, Word8, Word8) -> m (Image Float) toGreyScale arr-        = arr `deepSeqArray` computeP+        = computeP         $ R.map (* 255)         $ R.map floatLuminanceOfRGB8 arr  {-# NOINLINE toGreyScale #-}@@ -153,7 +151,7 @@ -- | Separable Gaussian blur in the X direction. blurSepX :: Monad m => Image Float -> m (Image Float) blurSepX arr-        = arr `deepSeqArray` computeP+        = computeP         $ forStencil2  BoundClamp arr           [stencil2|	1 4 6 4 1 |]	 {-# NOINLINE blurSepX #-}@@ -162,7 +160,7 @@ -- | Separable Gaussian blur in the Y direction. blurSepY :: Monad m => Image Float -> m (Image Float) blurSepY arr-	= arr `deepSeqArray` computeP+	= computeP 	$ R.cmap (/ 256) 	$ forStencil2  BoundClamp arr 	  [stencil2|	1@@ -176,7 +174,7 @@ -- | Compute gradient in the X direction. gradientX :: Monad m => Image Float -> m (Image Float) gradientX img- 	= img `deepSeqArray` computeP+ 	= computeP     	$ forStencil2 BoundClamp img 	  [stencil2|	-1  0  1 			-2  0  2@@ -187,7 +185,7 @@ -- | Compute gradient in the Y direction. gradientY :: Monad m => Image Float -> m (Image Float) gradientY img-	= img `deepSeqArray` computeP+	= computeP 	$ forStencil2 BoundClamp img 	  [stencil2|	 1  2  1 			 0  0  0@@ -198,13 +196,13 @@ -- | Classify the magnitude and orientation of the vector gradient. gradientMagOrient          :: Monad m -        => Float -> Image Float -> Image Float -> m (Image (Float, Int))+        => Float -> Image Float -> Image Float -> m (Image (Float, Word8))  gradientMagOrient !threshLow dX dY-        = [dX, dY] `deepSeqArrays` computeP+        = computeP         $ R.zipWith magOrient dX dY - where	magOrient :: Float -> Float -> (Float, Int)+ where	magOrient :: Float -> Float -> (Float, Word8) 	magOrient !x !y 		= (magnitude x y, orientation x y) 	{-# INLINE magOrient #-}@@ -215,7 +213,7 @@         {-# INLINE magnitude #-} 	         {-# INLINE orientation #-}-	orientation :: Float -> Float -> Int+	orientation :: Float -> Float -> Word8 	orientation !x !y  	 -- Don't bother computing orientation if vector is below threshold.@@ -233,7 +231,8 @@ 		!dNorm	= if dRot < 0 then dRot + 8 else dRot  		-- Doing explicit tests seems to be faster than using the FP floor function.-	   in	I# (if dNorm >= 4+	   in fromIntegral +               $ I# (if dNorm >= 4 		     then if dNorm >= 6 	   		  then if dNorm >= 7 			  	then 255#               -- 7@@ -251,17 +250,14 @@ 			else if dNorm >= 1 				then 128#               -- 1 				else 64#)               -- 0-- {-# NOINLINE gradientMagOrient #-}   -- | Suppress pixels that are not local maxima, and use the magnitude to classify maxima --   into strong and weak (potential) edges.-suppress :: Monad m => Float -> Float -> Image (Float, Int) -> m (Image Word8)+suppress :: Monad m => Float -> Float -> Image (Float, Word8) -> m (Image Word8) suppress !threshLow !threshHigh !dMagOrient- = dMagOrient `deepSeqArray` -   computeP+ = computeP  $ makeBordered2          (extent dMagOrient) 1   	(makeCursored (extent dMagOrient) id addDim comparePts)@@ -299,8 +295,7 @@ --         doesn't provide a fused mapFilter primitive yet. selectStrong :: Monad m => Image Word8 -> m (Array U DIM1 Int) selectStrong img- = img `deepSeqArray`-   let 	vec             = toUnboxed img+ = let 	vec             = toUnboxed img  	match ix	= vec `V.unsafeIndex` ix == edge Strong         {-# INLINE match #-}@@ -320,8 +315,7 @@ 	-> IO (Image Word8)  wildfire img arrStrong- = img `deepSeqArray` arrStrong `deepSeqArray`-   do	(sh, vec)	<- wildfireIO + = do	(sh, vec)	<- wildfireIO  	return	$ sh `seq` vec `seq` fromUnboxed sh vec   where	lenImg		= R.size $ R.extent img
examples/Laplace/src-repa/SolverGet.hs view
@@ -48,8 +48,7 @@ 	-> m (Array U DIM2 Double)  relaxLaplace arrBoundMask arrBoundValue arr-  = [arrBoundMask, arrBoundValue, arr] -   `deepSeqArrays` computeP+  = computeP   $ R.zipWith (+) arrBoundValue   $ R.zipWith (*) arrBoundMask   $ unsafeTraverse arr id elemFn
examples/Laplace/src-repa/SolverStencil.hs view
@@ -22,10 +22,10 @@  = go steps arrInit  where 	go 0 !arr = return arr 	go n !arr -         = do   arr'    <- relaxLaplace arrBoundMask arrBoundValue arr+         = do   arr'    <- relaxLaplace arr                 go (n - 1) arr' -        relaxLaplace arrBoundMask arrBoundValue arr+        relaxLaplace arr          = computeP          $ A.czipWith (+) arrBoundValue          $ A.czipWith (*) arrBoundMask@@ -34,4 +34,5 @@             [stencil2|   0 1 0                          1 0 1                           0 1 0 |] arr+ {-# NOINLINE solveLaplace #-}
examples/MMult/src-repa/Solver.hs view
@@ -11,8 +11,7 @@         -> m (Array U DIM2 Double)  mmultP arr brr - = [arr, brr] `deepSeqArrays` -   do   trr      <- transpose2P brr+ = do   trr      <- transpose2P brr         let (Z :. h1  :. _)  = extent arr         let (Z :. _   :. w2) = extent brr         computeP 
examples/Sobel/src-repa/Solver.hs view
@@ -14,7 +14,7 @@  gradientX :: Monad m => Image -> m Image gradientX img- 	= img `deepSeqArray` computeP+ 	= computeP  	$ forStencil2 (BoundConst 0) img 	  [stencil2|	-1  0  1 			-2  0  2@@ -24,7 +24,7 @@  gradientY :: Monad m => Image -> m Image gradientY img-	= img `deepSeqArray` computeP+	= computeP 	$ forStencil2 (BoundConst 0) img 	  [stencil2|	 1  2  1 			 0  0  0
repa-examples.cabal view
@@ -1,5 +1,5 @@ Name:                repa-examples-Version:             3.1.0.1+Version:             3.1.3.1 License:             BSD3 License-file:        LICENSE Author:              The DPH Team@@ -19,7 +19,7 @@  Executable repa-canny   Build-depends: -        base                 == 4.5.*,+        base                 == 4.*,         repa                 == 3.1.*,         repa-algorithms      == 3.1.*,         template-haskell     >= 2.5 && < 2.8@@ -36,7 +36,7 @@  Executable repa-mmult   Build-depends: -        base                 == 4.5.*,+        base                 == 4.*,         random               == 1.0.*,         repa                 == 3.1.*,         repa-io              == 3.1.*,@@ -57,7 +57,7 @@  Executable repa-laplace   Build-depends: -        base                 == 4.5.*,+        base                 == 4.*,         repa                 == 3.1.*,         repa-io              == 3.1.* @@ -74,7 +74,7 @@  Executable repa-fft2d   Build-depends: -        base                 == 4.5.*,+        base                 == 4.*,         repa                 == 3.1.*,         repa-algorithms      == 3.1.*,         repa-io              == 3.1.*@@ -93,7 +93,7 @@  Executable repa-fft2d-highpass   Build-depends: -        base                 == 4.5.*,+        base                 == 4.*,         repa                 == 3.1.*,         repa-algorithms      == 3.1.*,         repa-io              == 3.1.*@@ -113,7 +113,7 @@  Executable repa-fft3d-highpass   Build-depends: -        base                 == 4.5.*,+        base                 == 4.*,         repa                 == 3.1.*,         repa-algorithms      == 3.1.* @@ -131,7 +131,7 @@  Executable repa-blur   Build-depends: -        base                 == 4.5.*,+        base                 == 4.*,         vector               == 0.9.*,         repa                 == 3.1.*,         repa-algorithms      == 3.1.*@@ -150,7 +150,7 @@  Executable repa-sobel   Build-depends: -        base                 == 4.5.*,+        base                 == 4.*,         template-haskell     >= 2.5 && < 2.8,         repa                 == 3.1.*,         repa-algorithms      == 3.1.*@@ -170,7 +170,7 @@  Executable repa-volume   Build-depends: -        base                 == 4.5.*,+        base                 == 4.*,         repa                 == 3.1.*,         repa-io              == 3.1.*