@@ -465,14 +465,6 @@ const BandedBlockBandedBlock{T, BLOCKS, RAXIS} = SubArray{T,2,BandedBlockBandedM
465465BroadcastStyle (:: Type{<: BandedBlockBandedBlock} ) = BandedStyle ()
466466
467467
468- function inblockbands (V:: SubArray{<:Any,2,<:AbstractMatrix,<:Tuple{BlockSlice1,BlockSlice1},false} )
469- A = parent (V)
470- K_sl, J_sl = parentindices (V)
471- K, J = K_sl. block, J_sl. block
472- l,u = blockbandwidths (A)
473- - l ≤ Int (J- K) ≤ u
474- end
475-
476468function parentblock (V:: SubArray{T,2,<:AbstractMatrix,<:Tuple{BlockSlice{<:BlockIndexRange1},BlockSlice{<:BlockIndexRange1}}} ) where T
477469 A = parent (V)
478470 K_sl, J_sl = parentindices (V)
@@ -499,6 +491,29 @@ parentblocks2Int(V::BandedBlockBandedBlock)::Tuple{Int,Int} = Int(first(parentin
499491# #####################################
500492# BandedMatrix interface for Blocks #
501493# #####################################
494+ getindex (A:: BandedBlockBandedMatrix , KJ:: Block{2} ) = A[Block .(KJ. n)... ]
495+
496+ function inblockbands (A, K:: Block{1} , J:: Block{1} )
497+ l,u = blockbandwidths (A)
498+ - l ≤ Int (J- K) ≤ u
499+ end
500+
501+ function inblockbands (V:: SubArray{<:Any,2,<:AbstractMatrix,<:Tuple{BlockSlice1,BlockSlice1},false} )
502+ K_sl, J_sl = parentindices (V)
503+ inblockbands (parent (V), K_sl. block, J_sl. block)
504+ end
505+
506+ function getindex (A:: BandedBlockBandedMatrix{T} , K:: Block{1} , J:: Block{1} ) where T
507+ inblockbands (A, K, J) || return BandedMatrix {T} (undef, (length (axes (A,1 )[K]), length (axes (A,2 )[J])), (- 720 ,- 720 ))
508+ _BandedMatrix (A. data[A. u + K - J + 1 , J], length (axes (A,1 )[K]), subblockbandwidths (A)... )
509+ end
510+
511+ function getindex (A:: BandedBlockBandedMatrix{T} , KR:: BlockRange{1} , JR:: BlockRange{1} ) where T
512+ sh = Int (KR[1 ]- JR[1 ])
513+ l,u = blockbandwidths (A)
514+ _BandedBlockBandedMatrix (A. data[:,JR], axes (axes (A,1 )[KR],1 ), (l- sh, u+ sh), subblockbandwidths (A))
515+ end
516+
502517@inline function bandwidths (V:: SubArray{T,2,<:AbstractMatrix,<:Tuple{BlockSlice1,BlockSlice1}} ) where T
503518 inblockbands (V) && return subblockbandwidths (parent (V))
504519 (- 720 ,- 720 )
@@ -598,3 +613,16 @@ lmul!(x::Number, A::BandedBlockBandedMatrix) = (lmul!(x, A.data); A)
598613rmul! (A:: BandedBlockBandedMatrix , x:: Number ) = (rmul! (A. data, x); A)
599614* (x:: Number , A:: BandedBlockBandedMatrix ) = _BandedBlockBandedMatrix (x* A. data, axes (A,1 ), blockbandwidths (A), subblockbandwidths (A))
600615* (A:: BandedBlockBandedMatrix , x:: Number ) = _BandedBlockBandedMatrix (A. data* x, axes (A,1 ), blockbandwidths (A), subblockbandwidths (A))
616+
617+
618+ # ####
619+ # summary
620+ # ####
621+
622+ _bandedblockbanded_summary (io, B:: BandedBlockBandedMatrix{T} ) where T = print (io, " BandedBlockBandedMatrix{$T } with block-bandwidths $(blockbandwidths (B)) and sub-block-bandwidths block-bandwidths $(subblockbandwidths (B)) " )
623+ BlockArrays. _show_typeof (io:: IO , B:: DefaultBandedBlockBandedMatrix ) = _bandedblockbanded_summary (io, B)
624+ function BlockArrays. _show_typeof (io:: IO , B:: BandedBlockBandedMatrix )
625+ _bandedblockbanded_summary (io, B)
626+ print (io, " with data " )
627+ summary (io, B. data)
628+ end
0 commit comments