add: [CartesianIndex...] sparse method#600
add: [CartesianIndex...] sparse method#600kunzaatko wants to merge 3 commits intoJuliaSparse:mainfrom
Conversation
A method for specifying the indexes to fill with values directly as CartesianIndices.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #600 +/- ##
==========================================
+ Coverage 84.08% 84.19% +0.11%
==========================================
Files 12 12
Lines 9192 9309 +117
==========================================
+ Hits 7729 7838 +109
- Misses 1463 1471 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Another method that should be considered are ones that are created by using a range on instances of julia> CartesianIndex(3,4):CartesianIndex(4,9)
CartesianIndices((3:4, 4:9))
julia> CartesianIndex(3,4):CartesianIndex(4,9) |> typeof |> supertypes
(CartesianIndices{2, Tuple{UnitRange{Int64}, UnitRange{Int64}}}, AbstractMatrix{CartesianIndex{2}}, Any) |
|
Note that the |
|
Perhaps what you are describing is a more realistic use of the dense block. That was what I had in mind although the julia> sparse(CartesianIndex(12:14):CartesianIndex(15:17), ones(3*3), 20, 20) + sparse(CartesianIndex(2:4):CartesianIndex(5:7), ones(3*3), 20, 20)Which would create a sparse matrix with dense blocks inside. The structure of the type does not give the best memory usage for this case... |
NOTE: `CartesianIndex{2}` is no longer an abstract type so the function
no longer needs to be parametric.
|
Should we merge this? |
|
With the exception of documentation, I think there is nothing more to add to the constructor that allows for passing 2D |
|
@ViralBShah I think this is ready for merge if the CI passes. I added the documentation in the latest commit. You may check whether it is to your liking. |
|
There is a problem with ambiguities. I guess that I need to explicitly typeup all the methods |
Also fixed the methods to include all of the shortcuts (defaults) that the multiple vector method supports.
|
I am not sure what the best way to combat these ambiguities is. As I am not familiar with the code base, I am not sure, whether it would be OK, to assume that |
A method for specifying the indexes to fill with values directly as
CartesianIndices.
For example:
is now possible.