Skip to content

Commit 8a674d9

Browse files
Export the special span value for not-indexing an array dimension. (#61)
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.)
1 parent fa74dd8 commit 8a674d9

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/ArrayFire/Index.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ index (Array fptr) seqs =
4444
lookup :: Array a -> Array a -> Int -> Array a
4545
lookup a b n = op2 a b $ \p x y -> af_lookup p x y (fromIntegral n)
4646

47+
-- | A special value representing the entire axis of an 'Array'.
48+
span :: Seq
49+
span = Seq 1 1 0 -- From include/af/seq.h
50+
-- Hard-coded here because FFI cannot import static const values.
51+
4752
-- af_err af_assign_seq( af_array *out, const af_array lhs, const unsigned ndims, const af_seq* const indices, const af_array rhs);
4853
-- | Calculates 'mean' of 'Array' along user-specified dimension.
4954
--

0 commit comments

Comments
 (0)