-
Notifications
You must be signed in to change notification settings - Fork 1
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
Bugfix sparse_mul!
handling of beta
#18
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
==========================================
+ Coverage 63.13% 63.40% +0.26%
==========================================
Files 6 6
Lines 274 276 +2
==========================================
+ Hits 173 175 +2
Misses 101 101
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Co-authored-by: Matt Fishman <[email protected]>
It's a good question about whether we are assuming unstored values are zeros or not, and maybe that is not handled in a consistent way right now. Even though you can customize In terms of emptying the destination storage, I actually thought that was working, but I guess not: julia> using SparseArraysBase
julia> a = SparseArrayDOK{Float64}(2, 2)
2×2 SparseMatrixDOK{Float64, typeof(SparseArraysBase.default_getunstoredindex)}:
⋅ ⋅
⋅ ⋅
julia> a[1, 1] = 1
1
julia> a .*= 0
2×2 SparseMatrixDOK{Float64, typeof(SparseArraysBase.default_getunstoredindex)}:
0.0 ⋅
⋅ ⋅
julia> a[1, 1] = 1
1
julia> map!(Returns(0), a, a)
2×2 SparseMatrixDOK{Float64, typeof(SparseArraysBase.default_getunstoredindex)}:
0.0 ⋅
⋅ ⋅
julia> a[1, 1] = 1
1
julia> fill!(a, 0)
2×2 SparseMatrixDOK{Float64, typeof(SparseArraysBase.default_getunstoredindex)}:
0.0 ⋅
⋅ ⋅
julia> a[1, 1] = 1
1 The only one that works is: julia> SparseArraysBase.zero!(a)
2×2 SparseMatrixDOK{Float64, typeof(SparseArraysBase.default_getunstoredindex)}:
⋅ ⋅
⋅ ⋅ At some point I thought I had a codepath in fill, map, and broadcast that checked if it is filling with zero and in that case it would call
Good question, I didn't think too much about aliasing in the map operations. More broadly, we should discuss what we want the API to be for operating on just the stored values, in general I have been trying to push that down to an implementation detail so that higher level code and users don't have to think about that, since that can go wrong pretty easily (since it can depend on the ordering the data is stored if you have operations with multiple arrays). But maybe it would be good to make |
Co-authored-by: Matt Fishman <[email protected]>
This fixes #17 using the method discussed there, which pre-multiplies the output storage with
beta
.Some questions I had, which relate to some design choices:
beta = 0
. As a result, the current implementation will not discard stored zeros. Maybe we want a mechanism to be able to control that?map_stored!
, but it was unclear to me whether usinga_dest
both as input and output is something that is allowed by the API. I know theBase.map!
has a warning for this, and so we should probably decide whether the API supports that or not.