@@ -576,8 +576,10 @@ arguments(::ApplyLayout{typeof(vcat)}, V::SubArray{<:Any,2,<:Any,<:Tuple{<:Slice
576576arguments (:: ApplyLayout{typeof(hcat)} , V:: SubArray{<:Any,2,<:Any,<:Tuple{<:Any,<:Slice}} ) =
577577 view .(arguments (parent (V)), Ref (parentindices (V)[1 ]), Ref (:))
578578
579- copyto! (dest:: AbstractArray{T,N} , src:: SubArray{T,N,<:Vcat{T,N}} ) where {T,N} = vcat_copyto! (dest, arguments (src)... )
580- copyto! (dest:: AbstractMatrix{T} , src:: SubArray{T,2,<:Hcat{T}} ) where T = hcat_copyto! (dest, arguments (src)... )
579+ copyto! (dest:: AbstractArray{T,N} , src:: SubArray{T,N,<:Vcat{T,N}} ) where {T,N} =
580+ vcat_copyto! (dest, arguments (ApplyLayout {typeof(vcat)} (), src)... )
581+ copyto! (dest:: AbstractMatrix{T} , src:: SubArray{T,2,<:Hcat{T}} ) where T =
582+ hcat_copyto! (dest, arguments (ApplyLayout {typeof(hcat)} (), src)... )
581583
582584
583585_vcat_lastinds (sz) = _vcat_cumsum (sz... )
@@ -597,32 +599,35 @@ function _vcat_sub_arguments(::ApplyLayout{typeof(vcat)}, A, V)
597599 _view_vcat .(arguments (A), skr2)
598600end
599601_vcat_sub_arguments (:: ApplyLayout{typeof(hcat)} , A, V) = arguments (ApplyLayout {typeof(hcat)} (), V)
602+ _vcat_sub_arguments (:: PaddedLayout , A, V) = _vcat_sub_arguments (ApplyLayout {typeof(vcat)} (), A, V)
600603
601604_vcat_sub_arguments (A, V) = _vcat_sub_arguments (MemoryLayout (typeof (A)), A, V)
602605arguments (:: ApplyLayout{typeof(vcat)} , V:: SubArray{<:Any,1} ) = _vcat_sub_arguments (parent (V), V)
603606
604- function arguments (:: ApplyLayout{typeof(vcat)} , V:: SubArray{<:Any,2} )
607+ function arguments (L :: ApplyLayout{typeof(vcat)} , V:: SubArray{<:Any,2} )
605608 A = parent (V)
609+ args = arguments (L, A)
606610 kr,jr = parentindices (V)
607- sz = size .(arguments (A) ,1 )
611+ sz = size .(args ,1 )
608612 skr = intersect .(_argsindices (sz), Ref (kr))
609613 skr2 = broadcast ((a,b) -> a .- b .+ 1 , skr, _vcat_firstinds (sz))
610- _view_vcat .(arguments (A) , skr2, Ref (jr))
614+ _view_vcat .(args , skr2, Ref (jr))
611615end
612616
613617_view_hcat (a:: Number , kr, jr) = Fill (a,length (kr),length (jr))
614618_view_hcat (a, kr, jr) = view (a, kr, jr)
615619
616- function arguments (:: ApplyLayout{typeof(hcat)} , V:: SubArray )
620+ function arguments (L :: ApplyLayout{typeof(hcat)} , V:: SubArray )
617621 A = parent (V)
622+ args = arguments (L, A)
618623 kr,jr = parentindices (V)
619- sz = size .(arguments (A) ,2 )
624+ sz = size .(args ,2 )
620625 sjr = intersect .(_argsindices (sz), Ref (jr))
621626 sjr2 = broadcast ((a,b) -> a .- b .+ 1 , sjr, _vcat_firstinds (sz))
622- _view_hcat .(arguments (A) , Ref (kr), sjr2)
627+ _view_hcat .(args , Ref (kr), sjr2)
623628end
624629
625- function sub_materialize (:: ApplyLayout{typeof(vcat)} , V)
630+ function sub_materialize (:: ApplyLayout{typeof(vcat)} , V:: AbstractMatrix )
626631 ret = similar (V)
627632 n = 0
628633 _,jr = parentindices (V)
@@ -652,6 +657,26 @@ materialize!(M::MatMulMatAdd{<:AbstractColumnMajor,<:ApplyLayout{typeof(vcat)}})
652657materialize! (M:: MatMulVecAdd{<:AbstractColumnMajor,<:ApplyLayout{typeof(vcat)}} ) =
653658 materialize! (MulAdd (M. α,M. A,Array (M. B),M. β,M. C))
654659
660+ sublayout (:: PaddedLayout{L} , :: Type{I} ) where {L,I<: Tuple{AbstractUnitRange} } =
661+ PaddedLayout {typeof(sublayout(L(), I))} ()
662+ sublayout (:: PaddedLayout{L} , :: Type{I} ) where {L,I<: Tuple{AbstractUnitRange,AbstractUnitRange} } =
663+ PaddedLayout {typeof(sublayout(L(), I))} ()
664+
665+ function sub_materialize (:: PaddedLayout , v:: AbstractVector{T} ) where T
666+ A = parent (v)
667+ dat = paddeddata (A)
668+ (kr,) = parentindices (v)
669+ kr2 = kr ∩ axes (dat,1 )
670+ Vcat (lazy_getindex (dat, kr2), Zeros {T} (length (kr) - length (kr2)))
671+ end
672+
673+ function sub_materialize (:: PaddedLayout , v:: AbstractMatrix{T} ) where T
674+ A = parent (v)
675+ dat = paddeddata (A)
676+ kr,jr = parentindices (v)
677+ kr2 = kr ∩ axes (dat,1 )
678+ Vcat (lazy_getindex (dat, kr2, jr), Zeros {T} (length (kr) - length (kr2), length (jr)))
679+ end
655680
656681# # print
657682
0 commit comments