broadcast-binary-op ( a b quot -- c )


Vocabulary
arrays.shaped.private

Inputs
aan object
ban object
quotan object


Outputs
can object


Definition


:: broadcast-binary-op ( a b quot -- c )
a >shaped-array :> left b >shaped-array :> right left right
output-shape
:> dimensions dimensions row-major-strides :> strides left
shape>> dimensions length broadcast-strides
:> left-strides right shape>> dimensions length
broadcast-strides :> right-strides dimensions product <iota>
[| index |
strides dimensions
[| stride dimension | index stride /i dimension mod ]
2map :> coordinate coordinate left-strides [ * ] 2map
sum left underlying>> nth coordinate right-strides
[ * ] 2map sum right underlying>> nth quot call
] map dimensions <shaped-array> ; inline