First of all, I'm a total newbie in repa and I still consider myself a beginner in Haskell in general.
I need an effective array of triplets of doubles. The naïve approach would be [(Double, Double, Double)]
but that's not effective. I thought I could use repa as it is supposed to be very effective. However, I don't know how should I define an array of triplets.
I could do Array U DIM2 Double
and store the elements of the triplets in the second dimension (i.e. first index is the index of the triplet and the second index is the element of the triplet). However there is nothing that forces the second dimension to be only of size 3.
I need something like Array U DIM1 Vec3D
but that's not possible as Vec3D
is not instance of Data.Vector.Unboxed.Base.Unbox
.
I may be reading the documentation wrong, but I think Array U DIM1 (Double,Double,Double)
is exactly what you want (why don't you try it?). Before you tell me it is inefficient:
As far as I can tell, there is no way of introducing Array U sh u
without the constraints Shape sh
and Unbox u
. Therefore, any Array U sh u
will necessarily be efficient and fully unboxed.
In Unbox notice the instance (Unbox a, Unbox b, Unbox c) => Unbox (a, b, c)
, so Unbox (Double, Double, Double)
is derivable.