Skip to content

Conversation

johnomotani
Copy link

Take an existing BlockSkylineMatrix (or BlockBandedMatrix), and select a sub-matrix by passing UnitRanges for the rows and columns to select, returning a BlockSkylineMatrix (or BlockBandedMatrix).

Take an existing BlockSkylineMatrix (or BlockBandedMatrix), and select a
sub-matrix by passing UnitRanges for the rows and columns to select,
returning a BlockSkylineMatrix (or BlockBandedMatrix).
@johnomotani
Copy link
Author

I think I'm going to want a feature like this (actually possibly, eventually, even a more complicated version where I'd allow Vector{<:Int} indexing instead of the UnitRange...) to implement a matrix-solve algorithm based on a domain decomposition. Would be happy to just keep a function like this in a separate repo somewhere, but maybe it's generally useful?

Needs tests - I can probably work on some if there's interest in merging this PR.

Question: I've attempted to make the data copying efficient, but it's pretty ugly, so possibly fragile. Maybe an experienced BlockBandedMatrices.jl developer can see a better way?

Copy link

codecov bot commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 0% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.23%. Comparing base (dbb1e50) to head (df22d67).

Files with missing lines Patch % Lines
src/BlockSkylineMatrix.jl 0.00% 57 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #229      +/-   ##
==========================================
- Coverage   88.31%   85.23%   -3.09%     
==========================================
  Files          11       11              
  Lines        1113     1172      +59     
==========================================
+ Hits          983      999      +16     
- Misses        130      173      +43     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

bi_start = findblockindex.(axes(A), (rows.start, cols.start))
bi_stop = findblockindex.(axes(A), (rows.stop, cols.stop))

first_block = Int64.(BlockArrays.block.(bi_start))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be Int, not Int64

last_blockindices = Int64.(BlockArrays.blockindex.(bi_stop))

orig_blocksizes = blocksizes(A)
orig_row_sizes = [bs[1] for bs view(orig_blocksizes, :, 1)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very questionable. I think you might want to be using blockaxes or blocklengths.

I'm not going to review the rest since it all seems overly complicated.

not guaranteed that the `data` for the result is a contiguous subset of `A.data`.
"""
function BlockSkylineMatrix(A::BlockSkylineMatrix{T,DATA,BS}, rows::UnitRange,
cols::UnitRange) where {T,DATA,BS}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want AbstractUnitRange

`rows` and `columns`. This function allocates new memory and copies data, because it is
not guaranteed that the `data` for the result is a contiguous subset of `A.data`.
"""
function BlockSkylineMatrix(A::BlockSkylineMatrix{T,DATA,BS}, rows::UnitRange,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced this is the right name. The comment isn't exactly clear what this doing.

@dlfivefifty
Copy link
Member

Adding tests would make it clear what exactly this is doing.

I think this seems overly complicated. I'm pretty sure you can accomplish the same thing in a couple of lines using blockaxes. Once I understand what you are doing I can make some more suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants