Skip to content
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

Taking Sparse Arrays Seriously #19573

Closed
oscardssmith opened this issue Dec 13, 2016 · 2 comments
Closed

Taking Sparse Arrays Seriously #19573

oscardssmith opened this issue Dec 13, 2016 · 2 comments

Comments

@oscardssmith
Copy link
Member

oscardssmith commented Dec 13, 2016

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.

@tkelman
Copy link
Contributor

tkelman commented Dec 13, 2016

duplicate of #10410, see also #7010

@oscardssmith
Copy link
Member Author

Swear I looked for that, I thought I'd seen this idea somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants