-
-
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
full is a no-op on views of sparse objects #14255
Comments
Note that it's good practice to hit I think this is a special case of JuliaLang/LinearAlgebra.jl#231 and we may as well start making progress on some pieces of it. I agree with your assessment that writing special methods would be the simpler place to start, but implementing more support for operating on views of sparse matrices would be more beneficial long-term. |
To confirm my understanding of JuliaLang/LinearAlgebra.jl#231, the plan is to deprecate |
Either way. Plans need someone to start work on them and see how it goes, and if |
I think it's a fair conclusion from JuliaLang/LinearAlgebra.jl#231. It might also be worth noting that you can simply write |
|
Is |
From discussion in JuliaLang/LinearAlgebra.jl#283. JuliaLang/LinearAlgebra.jl#231 is also relevant.
On views of
SparseVector
s andSparseMatrixCSC
s,full
falls back tofull(x::AbstractArray) = x
from 4ab4ba7/base/abstractarray.jl#L435. Henceyields
rather than dense copies as
full
does when operating directly onSparseVector
s andSparseMatrixCSC
s.Glancing at the method for
full(::AbstractSparseVector)
, I see two potential fixes: (1) write a method forfull
on views ofSparseVector
s, independent offull(::AbstractSparseVector)
; or (2) implement the operations on whichfull(::AbstractSparseVector)
depends for views ofSparseVector
s, namelynonzeroinds
andnonzeros
, and either generalizeAbstractSparseVector
to include views ofSparseVector
s or generalize the signature offull(::AbstractSparseVector)
. Approach (2) is more generic, though chances are (1) would be easier.Glancing at the method for
full(::SparseMatrixCSC)
, I similarly see two potential fixes: (1) write a method forfull
on views ofSparseMatrixCSC
s independent offull(::SparseMatrixCSC)
; or (2) generalizefull(::SparseMatrixCSC)
such that it relies onnnz
,nonzeros
,rowvals
, andnzrange
rather than directly accessing the underlyingSparseMatrixCSC
data structure, implement those operations for views ofSparseMatrixCSC
s, and then generalize the signature offull(::SparseMatrixCSC)
. Again approach (2) is more generic, but in this case (1) is definitely easier.Thoughts? Should this wait for resolution of JuliaLang/LinearAlgebra.jl#231?
Edit: Corrected ref. Thanks Tony!
The text was updated successfully, but these errors were encountered: