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

Module accessors_macros_write

Search:
Group by:

Macros

macro `[]=`[T](t: var Tensor[T]; args: varargs[untyped]): untyped
Modifies a tensor inplace at the corresponding location or slice
Input:
  • a var tensor
  • a location:
    • specific coordinates (varargs[int])
    • or a slice (cf. tutorial)
  • a value:
    • a single value that will
      • replace the value at the specific coordinates
      • or be applied to the whole slice
    • an openarray with a shape that matches the slice
    • a tensor with a shape that matches the slice
Result:
  • Nothing, the tensor is modified in-place
Usage:
  • Assign a single value - foo[1..2, 3..4] = 999
  • Assign an array/seq of values - foo[0..1,0..1] = [[111, 222], [333, 444]]
  • Assign values from a view/Tensor - foo[^2..^1,2..4] = bar
  • Assign values from the same Tensor - foo[^2..^1,2..4] = foo[^1..^2|-1, 4..2|-1]
  Source Edit