-
-
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
recognize Adjoint/Transpose of sparse array as sparse #34266
Conversation
@test issparse(v) | ||
@test issparse(v') | ||
@test issparse(transpose(v)) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to add a test for the sparse matrix adjoint case too, which has the same bug, which I believe this PR should fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ten lines above these. ;-)
Consider also:
You may want to do:
However, this may trigger a runtime call to If it isn't might be good to make these proper traits that take only the type, Though perhaps |
What do you mean? I liked the trait idea very much, actually. That would also resolve stuff like this. julia> A = UpperTriangular(sprand(10,10,0.2))';
julia> issparse(A)
false Should we merge this as is (because it closes another concrete issue) and open a new issue to discuss how many layers of wrapping should be considered as sparsity-preserving? |
I am in favour of merging this one and opening a new one for the larger sparsity preserving discussion. |
Well it depends what one is promising to do by returning |
I just checked: the harder versions like doing this for all arrays that have |
Would issparse(S::LinearAlgebra.Symmetric) = issparse(S.data) and alike be also acceptable? That would make |
Not that AFAICT, there is a convention (which may not have ever been written down).
Not in this case.
|
Oh, I see, so I could extend the issparse(S::LinearAlgebra.Symmetric{<:Any,<:AbstractSparseMatrix}) = true
issparse(S::LinearAlgebra.Hermitian{<:Any,<:AbstractSparseMatrix}) = true
issparse(S::LinearAlgebra.LowerTriangular{<:Any,<:AbstractSparseMatrix}) = true
issparse(S::LinearAlgebra.UnitLowerTriangular{<:Any,<:AbstractSparseMatrix}) = true
issparse(S::LinearAlgebra.UpperTriangular{<:Any,<:AbstractSparseMatrix}) = true
issparse(S::LinearAlgebra.UnitUpperTriangular{<:Any,<:AbstractSparseMatrix}) = true ? EDIT: The |
Yep, and most of:
Not the last though, that will infinite loop. But on that basis idea, get all the wrapper arrays:
Which also still constant folds away.
|
@oxinabox So what's the conclusion? I'm not familiar with LLVM optimization and don't know how to read |
@ViralBShah was right, this is too much. |
Closes #34253.