Questions tagged [repa]

Repa is a Haskell package for high performance, regular, shape polymorphic parallel arrays.

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 +RTS -Nwhatever on the command line when running the program.

104 questions
10
votes
3 answers

Haskell repa --- mapping with indices

Imagine I want to map a function over an array, but the function has a type not just of a -> b but a -> Int -> b i.e. the function also takes an index. How do I do that?
Yrogirg
  • 2,301
  • 3
  • 22
  • 33
8
votes
1 answer

Haskell Repa stencil hacks

The Problem I'm trying to understand how Repa works and I was plaing with a "blur" example code from Repa Examples package. The code uses stencil2 Quasi Quote: [stencil2| 2 4 5 4 2 4 9 12 9 4 5 12 15 12 5 …
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
8
votes
1 answer

Calculate an image histogram with repa

I'm loading an RGB image from disk with JuicyPixels-repa. Unfortunately the Array representation of the image is Array F DIM3 Word8 where the inner dimension is the RGB pixels. That's a bit incompatibe with existing repa imageprocessing algorithms…
7
votes
1 answer

Repa Without Parallelization

I really like Repa's interface, even regardless of its concurrency capabilities. And I actually need repa's arrays to be sequential, since my arrays are relatively small ones and parallelization on them is useless, even harmful. However I do use…
Yrogirg
  • 2,301
  • 3
  • 22
  • 33
7
votes
2 answers

How to take an array slice with Repa over a range

I am attempting to implement a cumulative sum function using Repa in order to calculate integral images. My current implementation looks like the following: cumsum :: (Elt a, Num a) => Array DIM2 a -> Array DIM2 a cumsum array = traverse array id…
nightski
  • 513
  • 2
  • 13
7
votes
1 answer

Haskell: parallel computation and the 'sequential property' of monads

I am confused about why the REPA function computeP packs its result in a monad. It has the following type signature. computeP :: (Load r1 sh e, Target r2 e, Source r2 e, Monad m) => Array r1 sh e -> m (Array r2 sh e) In this tutorial it…
Safron
  • 802
  • 1
  • 11
  • 23
7
votes
1 answer

Difference between Repa and DPH

I recently read the paper on upcoming generalized stream fusion in vector and DPH libraries. It seems to be very interesting development. I am now starting to experiment with DPH (starting with GHC 7.6, and plan to upgrade to 7.8 SIMD version when…
Sal
  • 4,312
  • 1
  • 17
  • 26
7
votes
2 answers

Haskell repa - how to reduce array and return index?

In GNU Octave this code - [e, ix] = min(X); will return minimum element and it's location. How do you this in repa for arbitrary binary function? This is what I came up with: min x = z $ foldl' f (e,0,0) es where (e:es) = toList x f…
EvgenijM86
  • 2,149
  • 1
  • 17
  • 10
6
votes
1 answer

What's wrong with using Identity monad with mmultP when using repa?

I do not understand why this program using repa: import Data.Array.Repa import Data.Array.Repa.Algorithms.Matrix import Data.Functor.Identity go = runIdentity $ do let mat = fromListUnboxed (ix2 2 2) [1..4] let ins = fromListUnboxed (ix2 2 1)…
rityzmon
  • 1,945
  • 16
  • 26
6
votes
1 answer

Dynamic programming in repa

Two related questions. Is there a reason why there is no mutable (ST monad) implementation of repa arrays? Equivalent to Data.Vector.Mutable but with a shape. Related to this, how is one supposed to implement dynamic programming algorithms (array…
Federico Squartini
  • 1,188
  • 8
  • 14
6
votes
2 answers

How do you compute a[i] = f(a[i-1]) in Repa?

Is it possible to compute an array which depends on the past value(s) (i.e., lesser indexes), in Repa? Initial part(s) of the array (e.g., a[0]) is given. (Note that I am using C-like notation to indicate an element of array; please don't…
tkf
  • 2,990
  • 18
  • 32
5
votes
1 answer

Repa --- How to make a Read instance?

What is the best way to make type Configuration = Array DIM1 (Double, Double, Double) an instance of Read? So later I could derive data SimulationData = SD Configuration Double StdGen Int to be an instance of Read too.
Yrogirg
  • 2,301
  • 3
  • 22
  • 33
5
votes
0 answers

How do I apply Repa stencils with arbitrary dimension?

In the Repa package there are stencils that allow values to be calculated from neighbouring values in a convenient way (useful for convolutions, image blurring, diffusion simulations etc). In the current Repa package I can make stencils with any…
user668074
  • 1,111
  • 10
  • 16
5
votes
1 answer

How to fold a Repa array into an arbitrary value?

All the reduction functions of Repa fold back into the same types as the array contents. For example: foldAllP :: (Shape sh, Source r a, Elt a, Unbox a, Monad m) => (a -> a -> a) -> a -> Array r sh a -> m a foldAllS :: (Shape sh, Source r a, Elt a,…
user1002430
5
votes
1 answer

Why is there no mapM for repa arrays?

Background I am using repa more as a "management" tool. I pass around reactive-bananas AddHandlers in an Array: Array D DIM2 (AddHandler Bool). Currently I am using this kludge: mapMArray :: (Monad m, R.Source r a, R.Shape sh) => (a -> m b) ->…
fho
  • 6,787
  • 26
  • 71