-
-
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
Avoid reading inactive rowvals when computing the rank of a QRSparse #29925
Conversation
@@ -342,7 +342,7 @@ end | |||
_ret_size(F::QRSparse, b::AbstractVector) = (size(F, 2),) | |||
_ret_size(F::QRSparse, B::AbstractMatrix) = (size(F, 2), size(B, 2)) | |||
|
|||
LinearAlgebra.rank(F::QRSparse) = maximum(F.R.rowval) | |||
LinearAlgebra.rank(F::QRSparse) = reduce(max, view(F.R.rowval, 1:nnz(F.R)), init = eltype(F.R.rowval)(0)) |
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.
Use SparseArrays.nzvalview
instead?
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.
I'm using the rowval
s here, not the nzval
s. We could add rowvalview
but I think we should wait until there are more use cases.
Fixes JuliaLang/LinearAlgebra.jl#580