[Haskell-cafe] Data.Vector.Unboxed
Tom Nielsen
tanielsen at gmail.com
Wed Nov 9 12:43:48 CET 2011
Hi,
I don't know about Unboxed, but you can define a newtype wrapper
around Data.Vector.Storable that includes the size as a type-level
natural.
i.e.
data Z
data S n
newtype Vec n a = Vec (Vector a)
Then you can define a storable instance for Storable a => Vec n a, and
thus you can define a storable vector for Vec n a.
Not that you need something like this because storable instances must
have fixed size. I don't know if this is also true for Unbox.
I've done this using lists as the underlying container inside the
typed vectors, but you could use Data.Vector.Storable instead with
minimal effort:
https://github.com/glutamate/space/blob/master/VectorsL.hs
Tom
On Wed, Nov 9, 2011 at 9:56 AM, kaffeepause73 <kaffeepause73 at yahoo.de> wrote:
> Hello,
>
> quick question about unboxed Vectors :
>
> Is it possible to create an unboxed vector of unboxed vector ? :
>
>> import qualified Data.Vector.Unboxed as V
>> type UnboxedNestedVextor = V.Vector (V.Vector Int)
>
> Alternatively I would have to use:
>
>> import qualified Data.Vector.Unboxed as V
>> import qualified Data.Vector as VB
>
> type UnboxedNestedVextor = VB.Vector (V.Vector Int)
>
> Is there a rule of thumb how much quicker Unboxed Vectors are ?
>
> Cheers Phil
>
>
> --
> View this message in context: http://haskell.1045720.n5.nabble.com/Data-Vector-Unboxed-tp4977289p4977289.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list