From e20fae811751bc95b746fc81ea7e69b18eba54c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Justus=20Sagem=C3=BCller?= Date: Fri, 21 Jun 2024 01:47:21 +0200 Subject: [PATCH] Export the special `span` value for not-indexing an array dimension. This is quite important for effective array slicing, but not previously exposed. (The value could easily be hard-coded at each use site, but that would make for cryptic code, not to mention unsafe if the definition of af_span should ever change.) --- src/ArrayFire/Index.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ArrayFire/Index.hs b/src/ArrayFire/Index.hs index c31eaee..aa17f1d 100644 --- a/src/ArrayFire/Index.hs +++ b/src/ArrayFire/Index.hs @@ -44,6 +44,11 @@ index (Array fptr) seqs = lookup :: Array a -> Array a -> Int -> Array a lookup a b n = op2 a b $ \p x y -> af_lookup p x y (fromIntegral n) +-- | A special value representing the entire axis of an 'Array'. +span :: Seq +span = Seq 1 1 0 -- From include/af/seq.h + -- Hard-coded here because FFI cannot import static const values. + -- af_err af_assign_seq( af_array *out, const af_array lhs, const unsigned ndims, const af_seq* const indices, const af_array rhs); -- | Calculates 'mean' of 'Array' along user-specified dimension. --