@@ -39,7 +39,7 @@ struct BandedBlockBandedMatrix{T, BLOCKS, RAXIS<:AbstractUnitRange{Int}} <: Abst
39
39
end
40
40
end
41
41
42
- const DefaultBandedBlockBandedMatrix{T} = BandedBlockBandedMatrix{T, BlockedMatrix{T, Matrix{T}, NTuple{ 2 ,DefaultBlockAxis}}, DefaultBlockAxis }
42
+ const DefaultBandedBlockBandedMatrix{T} = BandedBlockBandedMatrix{T, <: BlockedMatrix{T, Matrix{T}} }
43
43
44
44
@inline _BandedBlockBandedMatrix (data:: AbstractMatrix , axes:: NTuple{2,AbstractUnitRange{Int}} , lu:: NTuple{2,Int} , λμ:: NTuple{2,Int} ) =
45
45
_BandedBlockBandedMatrix (BlockedArray (data,(blockedrange (Fill (sum (λμ)+ 1 ,sum (lu)+ 1 )),axes[2 ])), axes[1 ], lu, λμ)
@@ -340,14 +340,30 @@ Base.size(arr::BandedBlockBandedMatrix) =
340
340
_BandedMatrix (view (A. data, Block (K- J+ u+ 1 , J)), length (axes (A,1 )[Block (K)]), subblockbandwidths (A)... )
341
341
end
342
342
343
+ @inline inbands_viewblock (A:: BandedBlockBandedMatrix , K:: Block{1} , J:: Block{1} ) = inbands_viewblock (A, Block (Int (K), Int (J)))
344
+
345
+ emptyview (A:: BlockedMatrix , J) = view (A. blocks, 1 : 0 , axes (A,2 )[J])
346
+ function emptyview (A, J)
347
+ V = view (A, Block (1 ), J)
348
+ view (V, 1 : 0 , 1 : size (V,2 ))
349
+ end
350
+
351
+ @inline function outbands_viewblock (A:: BandedBlockBandedMatrix , KJ:: Block{2} )
352
+ l,u = blockbandwidths (A)
353
+ K,J = KJ. n
354
+ # Need to make an empty banded matrix in a type-stable way
355
+ _BandedMatrix (emptyview (A. data, Block (J)), length (axes (A,1 )[Block (K)]), - 720 ,- 720 )
356
+ end
357
+
358
+
359
+
343
360
@inline function viewblock (A:: BandedBlockBandedMatrix , KJ:: Block{2} )
344
- @boundscheck checkbounds (A, KJ)
361
+ @boundscheck blockcheckbounds (A, KJ)
345
362
K,J = KJ. n
346
363
if - A. u ≤ K- J ≤ A. l
347
364
inbands_viewblock (A, KJ)
348
365
else
349
- dat = view (A. data, Block (1 ,1 ))
350
- _BandedMatrix (dat, length (axes (A,1 )[Block (K)]), size (dat,1 )- 1 ,0 )
366
+ outbands_viewblock (A, KJ)
351
367
end
352
368
end
353
369
363
379
@boundscheck checkbounds (A, i, j)
364
380
BI,BJ = findblockindex .(axes (A), (i,j))
365
381
if - A. l ≤ Int (block (BJ)- block (BI)) ≤ A. u
366
- V = view (A, block (BI),block (BJ))
382
+ V = inbands_viewblock (A, block (BI),block (BJ))
367
383
@inbounds V[blockindex (BI),blockindex (BJ)] = convert (T, v):: T
368
384
elseif ! iszero (v)
369
385
throw (BandError (A))
0 commit comments