Skip to content

Forward blocks to parent in block-blockrange views#282

Open
jishnub wants to merge 1 commit into
JuliaArrays:masterfrom
jishnub:blockviewforward
Open

Forward blocks to parent in block-blockrange views#282
jishnub wants to merge 1 commit into
JuliaArrays:masterfrom
jishnub:blockviewforward

Conversation

@jishnub

@jishnub jishnub commented Jun 25, 2023

Copy link
Copy Markdown
Member

After this,

julia> S = sprand(Float64,4,4,0.2);

julia> B = mortar(fill(S,3,3));

julia> SB = view(B, Block(1), BlockRange(2:3))
4×8 view(::BlockMatrix{Float64, Matrix{SparseMatrixCSC{Float64, Int64}}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}}, BlockSlice(Block(1),1:4), BlockSlice(BlockRange(2:3),5:1:12)) with eltype Float64 with indices Base.OneTo(4)×1:1:8:
 0.0       0.0      0.0  0.00.0       0.0      0.0  0.0
 0.158791  0.0      0.0  0.00.158791  0.0      0.0  0.0
 0.0       0.0      0.0  0.00.0       0.0      0.0  0.0
 0.0       0.96011  0.0  0.00.0       0.96011  0.0  0.0

julia> view(SB, Block(1), Block(2))
4×4 SparseMatrixCSC{Float64, Int64} with 2 stored entries:
                        
 0.158791                
                        
          0.96011        

The view is forwarded to the parent block array, even when the parentindices of the view is a mix of Block and BlockRanges. On master, this works only if the parentindices are all BlockRanges. This, using lmul! instead of LMul in the matrix-multiplication method, makes the following faster:

julia> S = sprand(Float64,400,400,0.01);

julia> B = mortar(fill(S,3,3));

julia> U = UpperTriangular(B);

julia> v = Float64[1:size(B,2);];

julia> @btime $U * $v;
  10.724 ms (42 allocations: 12.42 KiB) # master
  2.999 ms (30 allocations: 11.55 KiB) # PR

@codecov

codecov Bot commented Jun 25, 2023

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.16%. Comparing base (a930509) to head (d316e9c).
⚠️ Report is 146 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #282      +/-   ##
==========================================
- Coverage   92.18%   92.16%   -0.02%     
==========================================
  Files          16       16              
  Lines        1484     1481       -3     
==========================================
- Hits         1368     1365       -3     
  Misses        116      116              

☔ View full report in Codecov by Harness.
📢 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.

@jishnub jishnub force-pushed the blockviewforward branch from 9ea8992 to d316e9c Compare June 28, 2023 09:26
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.

1 participant