diff --git a/base/broadcast.jl b/base/broadcast.jl index f7e7a3725c9ca..8465b50ddc333 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -512,6 +512,20 @@ julia> Broadcast.combine_axes(1, 1, 1) @inline combine_axes(A, B) = broadcast_shape(axes(A), axes(B)) combine_axes(A) = axes(A) +""" + broadcast_shape(As...) -> Tuple + +Determine the result axes for broadcasting across all axes (size Tuples) in `As`. + +```jldoctest +julia> Broadcast.broadcast_shape((1,2), (2,1)) +(2, 2) + +julia> Broadcast.broadcast_shape((1,), (1,5), (4,5,3)) +(4, 5, 3) +``` +""" +function broadcast_shape end # shape (i.e., tuple-of-indices) inputs broadcast_shape(shape::Tuple) = shape broadcast_shape(shape::Tuple, shape1::Tuple, shapes::Tuple...) = broadcast_shape(_bcs(shape, shape1), shapes...)