aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Mixed/XArray.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/Array/Mixed/XArray.hs')
-rw-r--r--src/Data/Array/Mixed/XArray.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Data/Array/Mixed/XArray.hs b/src/Data/Array/Mixed/XArray.hs
index 91a11ed..93484dc 100644
--- a/src/Data/Array/Mixed/XArray.hs
+++ b/src/Data/Array/Mixed/XArray.hs
@@ -15,6 +15,9 @@
module Data.Array.Mixed.XArray where
import Control.DeepSeq (NFData)
+import Data.Array.Internal.RankedG qualified as ORG
+import Data.Array.Internal.RankedS qualified as ORS
+import Data.Array.Internal qualified as OI
import Data.Array.Ranked qualified as ORB
import Data.Array.RankedS qualified as S
import Data.Coerce
@@ -59,6 +62,12 @@ fromVector sh v
toVector :: Storable a => XArray sh a -> VS.Vector a
toVector (XArray arr) = S.toVector arr
+-- | This allows observing the strides in the underlying orthotope array. This
+-- can be useful for optimisation, but should be considered an implementation
+-- detail: strides may change in new versions of this library without notice.
+arrayStrides :: XArray sh a -> [Int]
+arrayStrides (XArray (ORS.A (ORG.A _ (OI.T strides _ _)))) = strides
+
scalar :: Storable a => a -> XArray '[] a
scalar = XArray . S.scalar