aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-05-26 14:38:07 +0200
committerTom Smeding <tom@tomsmeding.com>2024-05-26 14:38:07 +0200
commit9f86a7de646ab3daa80656f0d30eaacb396d6875 (patch)
tree6e5085eb4c3bf934db11f77453f49c0e56e0da71 /src/Data/Array
parentaf06ef345d22df015ac8a0ab069438c180ab3e94 (diff)
Use fast C ops for X.sumFull
Diffstat (limited to 'src/Data/Array')
-rw-r--r--src/Data/Array/Mixed.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Data/Array/Mixed.hs b/src/Data/Array/Mixed.hs
index 080c458..d61969f 100644
--- a/src/Data/Array/Mixed.hs
+++ b/src/Data/Array/Mixed.hs
@@ -817,8 +817,12 @@ transpose2 ssh1 ssh2 (XArray arr)
, let n1 = ssxLength ssh1
= XArray (S.transpose (ssxIotaFrom n1 ssh2 ++ ssxIotaFrom 0 ssh1) arr)
-sumFull :: (Storable a, Num a) => XArray sh a -> a
-sumFull (XArray arr) = S.sumA arr
+sumFull :: (Storable a, NumElt a) => XArray sh a -> a
+sumFull (XArray arr) =
+ S.unScalar $
+ numEltSum1Inner (SNat @0) $
+ S.fromVector [product (S.shapeL arr)] $
+ S.toVector arr
sumInner :: forall sh sh' a. (Storable a, NumElt a)
=> StaticShX sh -> StaticShX sh' -> XArray (sh ++ sh') a -> XArray sh a