aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Mixed.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-05-20 23:25:36 +0200
committerTom Smeding <tom@tomsmeding.com>2024-05-20 23:25:36 +0200
commitd8d8fc39c6d52b0960c89f38bfa8ec3969a8ca02 (patch)
tree4cd0c9cf0ef6ac5ab60953bea824133e2fa8f4bf /src/Data/Array/Mixed.hs
parentdc9db431fea6bee2aa6533b9df7dee44c002f252 (diff)
iota
Diffstat (limited to 'src/Data/Array/Mixed.hs')
-rw-r--r--src/Data/Array/Mixed.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Data/Array/Mixed.hs b/src/Data/Array/Mixed.hs
index 1dc6b58..ef036af 100644
--- a/src/Data/Array/Mixed.hs
+++ b/src/Data/Array/Mixed.hs
@@ -782,3 +782,7 @@ reshapePartial ssh1 ssh' sh2 (XArray arr)
| Dict <- lemKnownNatRankSSX (ssxAppend ssh1 ssh')
, Dict <- lemKnownNatRankSSX (ssxAppend (staticShapeFrom sh2) ssh')
= XArray (S.reshape (shapeLshape sh2 ++ drop (lengthShX sh2) (S.shapeL arr)) arr)
+
+-- this was benchmarked to be (slightly) faster than S.iota, S.generate and S.fromVector(VS.enumFromTo).
+iota :: (Enum a, Storable a) => SNat n -> XArray '[Just n] a
+iota sn = XArray (S.fromVector [fromSNat' sn] (VS.fromListN (fromSNat' sn) [toEnum 0 .. toEnum (fromSNat' sn - 1)]))