-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue-pr: extend sparse broadcast[!] to one- and two-dimensional Arrays #20007
Conversation
…unate Broadcast complexity combinatorial explosion edition).
Could a mechanism like the for |
promote_containertype(::Type{Matrix}, ::Type{Any}) = Matrix | ||
promote_containertype(::Type{Any}, ::Type{Matrix}) = Matrix | ||
|
||
promote_containertype(::Type{Vector}, ::Type{Matrix}) = Matrix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you replace definitions like this one with a general definition along the lines of this? Would it help fixing the problem?
promote_containertype{S<:Array, T<:Array}(::Type{S}, ::Type{T}) =
Array{promote_type(eltype(S), eltype(T)), max(ndim(S), ndim(T))}`
(The element type isn't needed here of course, but I don't know how to create the Array{T, N}
type without speciying T
.)
Could you expand?
Though differentiating Thanks and best! |
Makes sense. What's the problem then? :-) |
The comments in the second/terminating code block in the original post describe the (two) issues, though not eloquently. A little expansion below: The first issue: The second issue: When teaching Best! |
shall we close this one? |
Sounds good! |
This pull request extends sparse
broadcast[!]
to one- and two-dimensional Arrays (via promotion to sparse, as with structured matrices), addressing #11474:Though it works, this pull request probably should not be merged (or only as a stopgap). It serves mainly to illustrate an issue with the
broadcast
containertype promotion mechanism. The comments in this pull request describe that issue at length (partly copied below) followed by an illustration. I plan to sketch an implementation of the proposal in those comments in another PR. Best!