summaryrefslogtreecommitdiff
path: root/src/Array.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2025-02-28 16:11:14 +0100
committerTom Smeding <tom@tomsmeding.com>2025-02-28 16:11:14 +0100
commite40e33bc16175b6a0180e3ef88d0a588819e6c37 (patch)
treefff0a39039edc117d86a5da1cd793bb633cc91c9 /src/Array.hs
parente9ab5d50093e48b64d758d67388ef32321ad1984 (diff)
Compile to C and load using dlopen
Diffstat (limited to 'src/Array.hs')
-rw-r--r--src/Array.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Array.hs b/src/Array.hs
index ef9bb8d..82c3f31 100644
--- a/src/Array.hs
+++ b/src/Array.hs
@@ -41,6 +41,10 @@ shapeSize :: Shape n -> Int
shapeSize ShNil = 1
shapeSize (ShCons sh n) = shapeSize sh * n
+shapeRank :: Shape n -> SNat n
+shapeRank ShNil = SZ
+shapeRank (sh `ShCons` _) = SS (shapeRank sh)
+
fromLinearIndex :: Shape n -> Int -> Index n
fromLinearIndex ShNil 0 = IxNil
fromLinearIndex ShNil _ = error "Index out of range"