broadcast

broadcast
(
S1
S2
)
(
S1 a0
,
S2 b0
)
if (
isSlice!S1 &&
isSlice!S2
)

Return Value

Type: auto

broadcasted slice. For example, when a has its shape [a, 1] and b has [1, b], this function returns expanded a and b with a broadcasted shape [a, b].

Examples

import mir.ndslice;
auto a = iota(1, 3, 1);
auto b = iota(1, 1, 2);
auto x = broadcast(a, b);
assert(broadcast(a, b)[0] == a.expand!2(2));
assert(broadcast(a, b)[1] == b.expand!1(3));

See Also

Meta