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

Fix multiplication, division between sparse and scalar #14973

Closed
wants to merge 1 commit into from

Conversation

tkelman
Copy link
Contributor

@tkelman tkelman commented Feb 7, 2016

for corner cases when the scalar is zero, Inf, or NaN

Returning dense data for sparse input is potentially really bad for
performance, but necessary to satisfy full(op(A, B)) == op(full(A), full(B))

todo:

for corner cases when the scalar is zero, Inf, or NaN

Returning dense data for sparse input is potentially really bad for
performance, but necessary to satisfy full(op(A, B)) == op(full(A), full(B))
@timholy
Copy link
Member

timholy commented Mar 22, 2016

This seems to have languished without review---we humans are woefully inadequate, and we need a bot that has the admirable attention to detail of, well, @tkelman to make sure that His Pull Requests Are Not Neglected.

👍 to this as a general strategy. Detailed comments coming.

if isfinite(B)
SparseMatrixCSC(A.m, A.n, copy(A.colptr), copy(A.rowval), A.nzval .* B)
else
densify_with_default(A, A.nzval .* B, zero(eltype(A)) .* B)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least theoretically, now that we have fast anonymous functions you could pass B and (x,y) ->x .* y, and thus skip the intermediate storage for A.nzval .* B.

@timholy
Copy link
Member

timholy commented Mar 22, 2016

LGTM.

@tkelman
Copy link
Contributor Author

tkelman commented Mar 23, 2016

Most of the discussion here happened in #14963, then I got distracted by other things and didn't finish my todo's. Will revisit and try your suggestion.

@Sacha0
Copy link
Member

Sacha0 commented Jun 28, 2016

@tkelman, is this still on your horizon? If not, would you appreciate someone else taking up the torch? Best!

@tkelman
Copy link
Contributor Author

tkelman commented Jun 28, 2016

Yes, and yes. Haven't had time to revisit this but would be quite pleased if you want to do so.

@tkelman
Copy link
Contributor Author

tkelman commented Jul 4, 2016

_fillnonzero! might help make this more concise now

@ViralBShah
Copy link
Member

This works fine now. We return a fully filled sparse matrix with the right entries.

@ViralBShah ViralBShah deleted the tk/sparsediv0 branch April 3, 2019 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sparse Sparse arrays
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants