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
5
votes
2 answers

Colour image file IO with Haskell repa array library

I'm exploring the Haskell repa library by trying out the multitude of programming examples. I'm aiming to implementation common image processing algorithms using repa. Repa examples There are some helpful code examples in the repa repository. They…
Rob Stewart
  • 1,812
  • 1
  • 12
  • 25
5
votes
2 answers

Expanding Repa array shapes

I'm writing a program that generates images, which I would like to bring into a Repa array. I'm currently using the type: data Colour = Colour Double Double Double to represent pixels, and I have a (probably inefficient but functional) function…
Tom Savage
  • 3,172
  • 4
  • 31
  • 31
4
votes
1 answer

Haskell: In the Repa library ... lists are not Elts, but what about "k-tuples"

I want to write an algorithm that traverses a 2dimensional matrix of size k by n+1 (say), and where each element in the array is a list of elements. These lists vary in size they may be length 1, 2, ... , k. I can even say, for sure, that in the…
4
votes
1 answer

Repa nested array definitions resulting in "Performing nested parallel computation sequentially..."

As part of a larger problem, I am trying to define an array inside an array like so: import Data.Array.Repa type Arr = Array DIM2 Int arr = force $ fromList (Z :. 5 :. 5) [1..25] :: Arr combined :: Arr combined = arr `deepSeqArray` traverse…
djmcgill
  • 75
  • 6
4
votes
1 answer

Haskell Repa --- select function is a bit confusing

I'm a bit confused with select function in repa package: select (\i -> True) (\i -> i) 10 gives the result [0,1,2,3,4,5,6,7,8] I thought i to be between 0 and 10 or 0 and 9. Why is it between 0 and 8? repa 2.0.2.1
Yrogirg
  • 2,301
  • 3
  • 22
  • 33
4
votes
0 answers

Effective way to change a single value in repa array

I try to use Gloss.Raster.Array to effectively plot a set of points on a screen. It uses an Array D DIM2 Color as a container of points to plot. Currently it is a 500x500 array, representing a 'bitmap'. Suppose that each frame I generate 1 new point…
dimsuz
  • 8,969
  • 8
  • 54
  • 88
4
votes
2 answers

How to create a 2-dimensional unboxed array from a list of 1-dimensional ones?

Repa has fromListUnboxed that allows to create a 1-dimensional array from a list of values. But how can I create a 2-dimensional one given a list of 1-dimensional unboxed ones (of equal lengths)?
Petr
  • 62,528
  • 13
  • 153
  • 317
4
votes
1 answer

Optimizing an average image colour program in haskell using REPA

The problem I've written a Haskell program that goes through a folder and finds the average colour of each image in the folder. It uses the repa-devil package from hackage to load images into repa arrays. I find the average by adding all the red,…
matio2matio
  • 303
  • 4
  • 11
4
votes
1 answer

How to import Repa

I'm really new to the Haskell world, so please excuse me for the stupid question. I instlled Haskell Platform, I executed cabal install repa and then tried to load a file with this code in WinGHCi import qualified Data.Array.Repa as R :m +…
Faery
  • 4,552
  • 10
  • 50
  • 92
4
votes
2 answers

Repa performance versus lists

In the Numeric Haskell Repa Tutorial Wiki, there is a passage that reads (for context): 10.1 Fusion, and why you need it Repa depends critically on array fusion to achieve fast code. Fusion is a fancy name for the combination of inlining and code…
Charles Durham
  • 1,707
  • 11
  • 17
4
votes
2 answers

How to allow unification of a type variable with different types?

I have a function with a following type signature {-# LANGUAGE FlexibleContexts #-} dataLat :: Load r DIM1 Double => (Array r DIM1 Double -> Array U DIM1 Double, Array U DIM1 Double) Array, U and DIM1 come from Repa library. dataLat creates…
Jan Stolarek
  • 1,409
  • 1
  • 11
  • 21
4
votes
0 answers

Resampling with Repa and Stencils

I wrote a simple image bilinear resampling algorithm with repa and since I need to use partitioned arrays to make it correct, I thought I would go whole hog and use stencils too and hopefully get faster loops. From my naive understanding of the way…
Jonathan Fischoff
  • 1,467
  • 12
  • 22
3
votes
2 answers

Essentially sequential array transformations in in Repa

I wonder whether there is an analogue of (//) in repa? It is needed for array transformations that cannot be parallelized. For example if the function requires the whole array to change a single entry of an array and than it is applied to a new…
Yrogirg
  • 2,301
  • 3
  • 22
  • 33
3
votes
1 answer

deepSeqArray of a single precision array

I have a vector of Float elements created by the getVectorFloat function. In order to make some measurements, I need to use deepSeqArray. However, I don't manage to do it. Here is my example: import Data.Array.Repa as R import…
3
votes
3 answers

Emulating non-rectangular arrays

Often times you want the performance of arrays over linked lists while having not conforming to the requirement of having rectangular arrays. As an example consider an hexagonal grid, here shown with the 1-distance neighbors of cell (3, 3) in medium…
tsorn
  • 3,365
  • 1
  • 29
  • 48