aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-05-14 10:29:29 +0200
committerTom Smeding <tom@tomsmeding.com>2024-05-14 10:29:29 +0200
commit172925e245728efb50d692c2f7460fd3e5f6dca2 (patch)
treec8f6f84ad4ff7013807830462d79e07fc5c18857 /src/Data/Array/Nested
parentc2fb07100ef8954ef51a5fabfe1b77cd40dd9b61 (diff)
toVector
Diffstat (limited to 'src/Data/Array/Nested')
-rw-r--r--src/Data/Array/Nested/Internal.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs
index 29592ac..3084e98 100644
--- a/src/Data/Array/Nested/Internal.hs
+++ b/src/Data/Array/Nested/Internal.hs
@@ -512,6 +512,12 @@ mfromVectorP sh v = M_Primitive (X.fromVector sh v)
mfromVector :: forall sh a. (KnownShapeX sh, Storable a, PrimElt a) => IShX sh -> VS.Vector a -> Mixed sh a
mfromVector sh v = fromPrimitive (mfromVectorP sh v)
+mtoVectorP :: Storable a => Mixed sh (Primitive a) -> VS.Vector a
+mtoVectorP (M_Primitive v) = X.toVector v
+
+mtoVector :: (Storable a, PrimElt a) => Mixed sh a -> VS.Vector a
+mtoVector arr = mtoVectorP (coerce toPrimitive arr)
+
mfromList1 :: (KnownShapeX '[n], Elt a) => NonEmpty a -> Mixed '[n] a
mfromList1 = mfromList . fmap mscalar
@@ -1036,6 +1042,12 @@ rfromVectorP sh v
rfromVector :: forall n a. (KnownINat n, Storable a, PrimElt a) => IShR n -> VS.Vector a -> Ranked n a
rfromVector sh v = coerce fromPrimitive (rfromVectorP sh v)
+rtoVectorP :: Storable a => Ranked n (Primitive a) -> VS.Vector a
+rtoVectorP = coerce mtoVectorP
+
+rtoVector :: (Storable a, PrimElt a) => Ranked n a -> VS.Vector a
+rtoVector = coerce mtoVector
+
rfromList :: forall n a. (KnownINat n, Elt a) => NonEmpty (Ranked n a) -> Ranked (S n) a
rfromList l
| Dict <- lemKnownReplicate (Proxy @n)
@@ -1236,6 +1248,12 @@ sfromVectorP v
sfromVector :: forall sh a. (KnownShape sh, Storable a, PrimElt a) => VS.Vector a -> Shaped sh a
sfromVector v = coerce fromPrimitive (sfromVectorP @sh @a v)
+stoVectorP :: Storable a => Shaped sh (Primitive a) -> VS.Vector a
+stoVectorP = coerce mtoVectorP
+
+stoVector :: (Storable a, PrimElt a) => Shaped sh a -> VS.Vector a
+stoVector = coerce mtoVector
+
sfromList :: forall n sh a. (KnownNat n, KnownShape sh, Elt a)
=> NonEmpty (Shaped sh a) -> Shaped (n : sh) a
sfromList l