You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been looking at the plethora of issues and attempts to fix sparse arrays and broadcast. For anyone not caught up on the general strife, here is a rough (although very incomplete) overview.
Current Problems:
#19561: broadcasting non numeric arrays causes problems because zero(::Type{Any}) doesn't exist #19372: When should broadcast return dense vs sparse arrays?
Current Consensus:
Implement zero for strings
f(A) returns sparse if A is sparse, and f is zero preserving.
f(A,B) returns sparse if A and B are sparse, and f is zero preserving on either both or one of the zeros.
higher order cases get complicated quickly.
Proposed Solution:
Implement a new type of sparse array that can have a custom set default element.
For the first issue, this allows the simple solution of making the default element '' which will allow broadcasts to work sensibly.
For the second, we get the quite nice property that f(A,B...X) can be done by iterating over the nonzero values of all the various arrays, and then switching the default value to f(0,0...0). This will be simple to code, and will contain almost all of the advantages of the current approach.
The text was updated successfully, but these errors were encountered:
I have been looking at the plethora of issues and attempts to fix sparse arrays and broadcast. For anyone not caught up on the general strife, here is a rough (although very incomplete) overview.
Current Problems:
#19561: broadcasting non numeric arrays causes problems because
zero(::Type{Any})
doesn't exist#19372: When should broadcast return dense vs sparse arrays?
Current Consensus:
Implement zero for strings
f(A)
returns sparse ifA
is sparse, andf
is zero preserving.f(A,B)
returns sparse ifA
andB
are sparse, andf
is zero preserving on either both or one of the zeros.Proposed Solution:
Implement a new type of sparse array that can have a custom set default element.
For the first issue, this allows the simple solution of making the default element
''
which will allow broadcasts to work sensibly.For the second, we get the quite nice property that
f(A,B...X
) can be done by iterating over the nonzero values of all the various arrays, and then switching the default value tof(0,0...0)
. This will be simple to code, and will contain almost all of the advantages of the current approach.The text was updated successfully, but these errors were encountered: