-
-
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
sparse vector divide by float gives full vector #14111
Comments
Looks like an oversight, as sparsity is preserved for sparse matrices. @augustinyiptong If you call A better fix would be to add a function like this: import Base.SparseArrays.nonzeroinds
./(x::AbstractSparseVector, a::Number) = SparseVector(length(x), copy(nonzeroinds(x)), nonzeros(x)./a) |
be sure to check for a zero (edit: or NaN) denominator. |
We can do the obvious fix for now - but I think sparse solvers can generally do better with sparse RHS. I'm not sure what the state of the art is on this question today though. |
Unless your matrix is diagonal, solving a linear system of equations doesn't generally preserve sparsity in the right hand side. Simplex is the usual poster child algorithm where sparse vectors play a crucial role. This issue is just about division by a scalar though, so "solvers" aren't so relevant here. |
closed by #15579 |
Hi
I have:
I do:
So far so good. If i do:
Why does it get converted to a full vector?
I am using Julia Version
0.5.0-dev+1158
Thanks, Gus
The text was updated successfully, but these errors were encountered: