Filling a 2D accelerate array one row at a time

136 Views Asked by At
λ> import Data.Array.Accelerate
λ> import Data.Array.Accelerate.Interpreter (run)

Say you have a a 2D accelerate array:

λ> :t arr
arr :: Acc (Array DIM2 Int)
λ> run $ unit $ shape arr
Scalar Z [Z :. 4 :. 3]

and a 1D accelerate vector of length 4 (the same as the number of colums of arr):

λ> :t vec
vec :: Acc (Array DIM1 Int)
λ> run $ unit $ shape vec
Scalar Z [Z :. 4]

and a function from a scalar to a vector of length 3:

expand :: Exp Int -> Acc (Array DIM1 Int)

How can you populate arr by mapping expand on vec?

The regular map from Prelude does not work on accelerate arrays. The map from Data.Array.Accelerate only maps from element to element.

0

There are 0 best solutions below