-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
The eltype of SparseMatrixCSC's colptr should be Int instead of Ti #38790
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
Comments
This analysis makes sense when considering the limit where the sparse matrix is close to dense. I think instead that the choice of having the same type for I also think that adding a type parameter to the |
Thank you for the comment! In our case, m ≈ 50,000,000, n ≈ 100,000 and each row stores only about 100 Boolean values.
I think so too. |
Ah yes, you are right at the transition.... You could always roll your own type and subtype I think that would be the best way for you to solve this problem neatly. If you do end up trying this, let us know which functions don't work. |
I think it's unlikely to be done if nobody does it. 😝 If you append a type parameter to the existing ones, then this should be non-breaking. Methods with signatures that parametrize the first two types (usually |
Hmm, It's tough to make a new type that can replace I thought that directly applying We will fork the repository, modify it, and try to use it for just our purpose. Thank you. |
I just reopened JuliaLang/LinearAlgebra.jl#446 in order to start a discussion for moving these implementations into their own packages, precisely to pave the way for having more first class sparse matrix representations, and more flexibility in the use of sparse direct solvers. |
This use case is very interesting and fun to read about! |
@ViralBShah |
I think the following suggestion is a simple and good solution and will work for us without much effort. |
julia/stdlib/SparseArrays/src/sparsematrix.jl
Line 22 in a813a6e
In the definition of the SparseMatrixCSC, the eltype
Ti
ofcolptr
is the same as that ofrowval
.Therefore, we have to set
Ti
with a capacity that can store the number of elements (colptr
), instead of a capacity that can store only the row number (rowval
).Since the length of
rowval
is up to m * n and the length ofcolptr
is only n + 1,rowval
requires much more memory.The value to be stored in
rowval
is only up to m, so we want to use the smallest eltype that can store m (e.g.: UInt32).If m <= typemax(UInt32), the value to be stored in
colptr
is up to m * n and it is quite possible that the value will be greater than typemax(UInt32).From the above, I think that the eltype of SparseMatrixCSC's
colptr
should be Int instead ofTi
.Best regards.
The text was updated successfully, but these errors were encountered: