aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested/Internal.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-04-20 21:56:12 +0200
committerTom Smeding <tom@tomsmeding.com>2024-04-20 22:08:07 +0200
commit2b0391b9a5885af1b551c83f2dc4b8ef2b48d7bf (patch)
tree92d555a5a4f1318967bf8ff1447fadc69a26bcda /src/Data/Array/Nested/Internal.hs
parent6fc6f4327391f14f026a9848f68a28e70cef6185 (diff)
fromList1 (the analogue to orthotope's fromList)
Diffstat (limited to 'src/Data/Array/Nested/Internal.hs')
-rw-r--r--src/Data/Array/Nested/Internal.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs
index f76b2ab..6f0cfc8 100644
--- a/src/Data/Array/Nested/Internal.hs
+++ b/src/Data/Array/Nested/Internal.hs
@@ -489,6 +489,9 @@ mfromVector sh v
| otherwise =
M_Primitive (X.fromVector sh v)
+mfromList1 :: (KnownShapeX '[n], Elt a) => NonEmpty a -> Mixed '[n] a
+mfromList1 = mfromList . fmap mscalar
+
munScalar :: Elt a => Mixed '[] a -> a
munScalar arr = mindex arr IZX
@@ -918,6 +921,9 @@ rfromVector sh v
| Dict <- lemKnownReplicate (Proxy @n)
= Ranked (mfromVector (ixCvtRX sh) v)
+rfromList1 :: Elt a => NonEmpty a -> Ranked I1 a
+rfromList1 = Ranked . mfromList . fmap mscalar
+
runScalar :: Elt a => Ranked I0 a -> a
runScalar arr = rindex arr IZR
@@ -1051,6 +1057,9 @@ sfromVector v
| Dict <- lemKnownMapJust (Proxy @sh)
= Shaped (mfromVector (ixCvtSX (cvtSShapeIxS (knownShape @sh))) v)
+sfromList1 :: (KnownNat n, Elt a) => NonEmpty a -> Shaped '[n] a
+sfromList1 = Shaped . mfromList . fmap mscalar
+
sunScalar :: Elt a => Shaped '[] a -> a
sunScalar arr = sindex arr IZS