-
Notifications
You must be signed in to change notification settings - Fork 38
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
Operations with Eye do not preserve sparsity #265
Comments
The broadcast is actually a bit involved, and defining everything here might not be the best idea. The interplay between the structured matrix broadcast style and the sparse matrix style is handled by Regarding julia> E = Eye(2,3)
2×3 Eye{Float64}
julia> kron(E, E)
4×9 Matrix{Float64}:
1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 The |
Right, I realize you can't make I guess another alternative is to return a |
Now the rectangular kron is also addressed in #268, and it'll return a sparse array |
julia> Eye(5)[:,:]
5×5 Matrix{Float64}:
1.0 0.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0 0.0
0.0 0.0 1.0 0.0 0.0
0.0 0.0 0.0 1.0 0.0
0.0 0.0 0.0 0.0 1.0 I'm not sure if it's worth adding BandedMatrices to the dependency. |
Adding banded matrices as a dependency won’t work we could add a new type called |
Note |
Hi, I've noticed that
SquareEye
, since it is aLinearAlgebra.Diagonal
preserves sparsity in many operations. For example:However, general
Eye
typically converts to a dense matrix:This was quite surprising to me. Could we add some operator overloads to keep things sparse in the
Eye
case?The text was updated successfully, but these errors were encountered: