[Haskell-cafe] Data.Vector.Unboxed

Daniel Peebles pumpkingod at gmail.com
Fri Nov 11 00:21:06 CET 2011


Yes, it does. You can only use members of the Elt class in repa arrays, and
Elt has Unbox as a superclass.

On Thu, Nov 10, 2011 at 5:03 PM, Yves Parès <limestrael at gmail.com> wrote:

> Does Repa always use unboxed Vectors?
> But a Repa array can store any element, so how does it handles types which
> haven't an unboxed equivalent? Or is the unboxing done automatically?
>
>
> 2011/11/10 Bas van Dijk <v.dijk.bas at gmail.com>
>
>> On 9 November 2011 22:33, kaffeepause73 <kaffeepause73 at yahoo.de> wrote:
>> > Repa is indeed very Interesting, but I have changing vector length in
>> the
>> > second dimension and later on only want to generate Data on demand. If
>> I use
>> > Matrices, I will use loads of space for no reason.
>>
>> Even if it is possible to create an unboxed vector of unboxed vectors,
>> if the inner unboxed vectors have variable lengths as you require,
>> indexing will become O(n) instead of O(1) because you need to traverse
>> the inner unboxed vectors and check their length to find the desired
>> index. I'm not sure that's what you want.
>>
>> > Seems like sticking to Boxed Vector for now is best Choice for me.
>>
>> Yes your second alternative: a boxed vector of unboxed vectors seems
>> to do what you want.
>>
>> > isn't data.vector also providing multidimensional arrays?
>>
>> I don't think so. All indexing functions get a single Int argument. Of
>> course it's easy to build a layer on top that adds more dimensions.
>>
>> > So is Repa just another Version of Data.Vector or is it building
>> another level on top.
>>
>> The latter, repa provides a layer on top of vector.
>>
>> Note that you can also convert Vectors to repa Arrays using:
>>
>> fromVector :: Shape sh => sh -> Vector a -> Array sh a
>>
>> I believe its O(1).
>>
>> > And when to use best which of the two ?
>>
>> I guess when your vectors are multi-dimensional and you want to
>> benefit from parallelism you should use repa instead of vector.
>>
>> Cheers,
>>
>> Bas
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111110/d2853665/attachment.htm>


More information about the Haskell-Cafe mailing list