aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Data/Array/Nested.hs1
-rw-r--r--src/Data/Array/Nested/Internal.hs8
2 files changed, 8 insertions, 1 deletions
diff --git a/src/Data/Array/Nested.hs b/src/Data/Array/Nested.hs
index 2208349..7298918 100644
--- a/src/Data/Array/Nested.hs
+++ b/src/Data/Array/Nested.hs
@@ -16,6 +16,7 @@ module Data.Array.Nested (
-- ** Conversions
rasXArrayPrim, rfromXArrayPrim,
rcastToShaped,
+ rfromOrthotope,
-- * Shaped arrays
Shaped(Shaped),
diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs
index a05ff84..8f18724 100644
--- a/src/Data/Array/Nested/Internal.hs
+++ b/src/Data/Array/Nested/Internal.hs
@@ -28,7 +28,7 @@
{-|
TODO:
-* Write `rconst :: OR.Array n a -> Ranked n a`
+(empty list)
-}
@@ -1403,6 +1403,12 @@ rtoList (Ranked arr)
rtoList1 :: Elt a => Ranked 1 a -> [a]
rtoList1 = map runScalar . rtoList
+rfromOrthotope :: PrimElt a => SNat n -> S.Array n a -> Ranked n a
+rfromOrthotope sn arr
+ | Refl <- lemRankReplicate sn
+ = let xarr = XArray arr
+ in Ranked (fromPrimitive (M_Primitive (X.shape (ssxFromSNat sn) xarr) xarr))
+
runScalar :: Elt a => Ranked 0 a -> a
runScalar arr = rindex arr ZIR