From 96795853db5a3ee85d7c838a508b4153988e6042 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Fri, 16 Jan 2026 19:14:20 +0100 Subject: C: Fix REDUCEFULL Only the last inner vector was kept... --- cbits/arith.c | 4 +++- ops/Data/Array/Strided/Arith/Internal.hs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cbits/arith.c b/cbits/arith.c index 1066463..ee248a4 100644 --- a/cbits/arith.c +++ b/cbits/arith.c @@ -494,7 +494,9 @@ static void print_shape(FILE *stream, i64 rank, const i64 *shape) { if (rank == 0) return arr[0]; \ typ result = 0; \ TARRAY_WALK_NOINNER(again, rank, shape, strides, { \ - REDUCE_BODY_CODE(op, typ, shape[rank - 1], strides[rank - 1], arr, arrlinidx, result); \ + typ dest = 0; \ + REDUCE_BODY_CODE(op, typ, shape[rank - 1], strides[rank - 1], arr, arrlinidx, dest); \ + result = result op dest; \ }); \ return result; \ } diff --git a/ops/Data/Array/Strided/Arith/Internal.hs b/ops/Data/Array/Strided/Arith/Internal.hs index d94fc65..7578dd8 100644 --- a/ops/Data/Array/Strided/Arith/Internal.hs +++ b/ops/Data/Array/Strided/Arith/Internal.hs @@ -396,6 +396,7 @@ vectorRedInnerOp sn@SNat valconv ptrconv fscale fred array@(Array sh strides off Nothing -> error "impossible" -- TODO: test handling of negative strides +-- TODO: simplify away normalised dimensions -- | Reduce full array {-# NOINLINE vectorRedFullOp #-} vectorRedFullOp :: forall a b n. (Num a, Storable a) -- cgit v1.2.3-70-g09d2