Repa array and Data.Vector.Storable.Mutable.

Hello I would like a function which allows to freeze a Mutable Vector into a Repa array. of type Array F DIM2 a It seems to me that the the foreignPtr ownership should be transfer to the Repa Array, but I can not find a way to do this... So what is the proper way to achieve this ? thansk for your help. Frederic

On 26 Apr 2019, at 9:14 am, PICCA Frederic-Emmanuel
wrote: Hello
I would like a function which allows to freeze a Mutable Vector into a Repa array. of type Array F DIM2 a It seems to me that the the foreignPtr ownership should be transfer to the Repa Array, but I can not find a way to do this...
So what is the proper way to achieve this ?
If it’s a boxed Data.Vector then you have to copy it, because the ForeignPtr representation is unboxed. Freeze the mutable vector with Data.Vector.freeze or unsafeFreeze, then apply Data.Array.Repa.Repr.Vector.fromVector. This gives you a boxed Repa representation, then copy it into the unboxed ForeignPtr representation with copyP. If you can build an unboxed Data.Vector.Storable instead, then apply unsafeToForeignPtr to get the guts of it, and give them to Data.Array.Repa.Repr.ForeignPtr.fromForeignPtr. Ben.
participants (2)
-
Ben Lippmeier
-
PICCA Frederic-Emmanuel