The broadcast style of SubArrray
(i.e. as obtained using view
) is a DefaultArrayStyle
:
julia> Base.BroadcastStyle(typeof(view(rand(10,10),2:3,3:4)))
Base.Broadcast.DefaultArrayStyle{2}()
yet it would be extremely useful, if it would automatically refer to the unwrapped array type such as returned by the unwrap_type
function in the Adapt.jl
package. In other words, it should be:
function Base.Broadcast.BroadcastStyle(W::Type{<:SubArray})
return Base.Broadcast.BroadcastStyle(Adapt.unwrap_type(W))
end
This would help tremendously with writing generic Adapt code.
Should this be part of Base Julia?