Fork me on GitHub
Arraymancer Technical reference Tutorial Spellbook (How-To's) Under the hood

Module accessors_macros_read

Search:
Group by:

Macros

macro `[]`[T](t: AnyTensor[T]; args: varargs[untyped]): untyped
Slice a Tensor or a CudaTensor
Input:
  • a Tensor or a CudaTensor
  • and:
    • specific coordinates (varargs[int])
    • or a slice (cf. tutorial)
Returns:
  • a value or a tensor corresponding to the slice
Warning ⚠ CudaTensor temporary default:
For CudaTensor only, this is a no-copy operation, data is shared with the input. This proc does not guarantee that a let value is immutable.
Usage:
  • Basic indexing - foo[2, 3]
  • Basic indexing - foo[1+1, 2*2*1]
  • Basic slicing - foo[1..2, 3]
  • Basic slicing - foo[1+1..4, 3-2..2]
  • Span slices - foo[_, 3]
  • Span slices - foo[1.._, 3]
  • Span slices - foo[_..3, 3]
  • Span slices - foo[_.._, 3]
  • Stepping - foo[1..3|2, 3]
  • Span stepping - foo[_.._|2, 3]
  • Span stepping - foo[_.._|+2, 3]
  • Span stepping - foo[1.._|1, 2..3]
  • Span stepping - foo[_..<4|2, 3]
  • Slicing until at n from the end - foo[0..^4, 3]
  • Span Slicing until at n from the end - foo[_..^2, 3]
  • Stepped Slicing until at n from the end - foo[1..^1|2, 3]
  • Slice from the end - foo[^1..0|-1, 3]
  • Slice from the end - expect non-negative step error - foo[^1..0, 3]
  • Slice from the end - foo[^(2*2)..2*2, 3]
  • Slice from the end - foo[^3..^2, 3]
  Source Edit