[BlockSparseArrays] Sub-slices of multiple blocks #1489
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds support for taking slices of multiple blocks at once (as proposed in ITensor/BlockSparseArrays.jl#2 and JuliaArrays/BlockArrays.jl#358), for example for a block sparse array:
we can now do this:
One thing you can see is that the implementation is pretty minimal, because it can make use of the infrastructure built for other slicing operations in BlockSparseArrays and the BlockArrays.jl package.
Additionally, I think this kind of slicing operation will be very useful for implementing low-rank block-wise matrix factorizations. For example, we could reduce the rank of an SVD like this:
which truncates the singular values and associated singular vectors of each block down to the specified block ranks:
This kind of slicing can be performed either with the syntax
I = [Block(1)[1:2], Block(2)[1:2]]
to define the slice of the blocks in each dimension as shown above or using the syntaxI = mortar([Block(1)[1:2], Block(2)[1:2]])
.mortar
is one of the BlockArrays.jl interfaces for making aBlockVector
, so it acts like a vector over[Block(1)[1], Block(1)[2], Block(2)[1], Block(2)[2]]
but keeps track of the block structure as well.To-do:
I = [Block(1)[1:2], Block(2)[1:2]]
, in addition to the current implementation which is based aroundI = mortar([Block(1)[1:2], Block(2)[1:2]])
.@ogauthe, @emstoudenmire