Fork me on GitHub

Tutorial: Broadcasting

Arraymancer supports explicit broadcasting with broadcast and its alias bc. And supports implicit broadcasting with operations beginning with a dot:

let j = [0, 10, 20, 30].toTensor.reshape(4,1)
let k = [0, 1, 2].toTensor.reshape(1,3)

echo j +. k
# Tensor[int] of shape "[4, 3]" on backend "Cpu"
# |0       1       2|
# |10     11      12|
# |20     21      22|
# |30     31      32|
Arraymancer Technical reference Tutorial Spellbook (How-To's) Under the hood