Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ end

resizedata!(B::CachedArray, mn...) = resizedata!(MemoryLayout(B.data), MemoryLayout(B.array), B, mn...)
resizedata!(B::AbstractCachedArray, mn...) = resizedata!(MemoryLayout(B.data), UnknownLayout(), B, mn...)
resizedata!(A, mn...) = A # don't do anything
resizedata!_layout(_, A, mn...) = A # don't do anything


resizedata!(A, mn...) = resizedata!_layout(MemoryLayout(A), A, mn...)
function resizedata!(A::AdjOrTrans, m, n)
resizedata!(parent(A), n, m)
A
Expand Down Expand Up @@ -615,4 +618,13 @@ CachedArray(data::AbstractMatrix, array::AbstractQ) = CachedArray(data, array, s
CachedArray(data::AbstractMatrix{T}, array::AbstractQ{T}, datasize::NTuple{2,Int}) where T =
CachedMatrix{T,typeof(data),typeof(array)}(data, array, datasize)

length(A::CachedMatrix{<:T,<:AbstractMatrix{T},<:AbstractQ{T}}) where T = prod(size(A.array))
length(A::CachedMatrix{<:T,<:AbstractMatrix{T},<:AbstractQ{T}}) where T = prod(size(A.array))



###
# resizedata! for types
###


resizedata!_layout(lay::BroadcastLayout, b, m...) = resizedata!.(arguments(lay, b), m...)
15 changes: 2 additions & 13 deletions src/padded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,8 @@ function rowsupport(lay::Union{PaddedColumns{Lay}, PaddedLayout{Lay}}, A, k) whe
isempty(k̃) ? convert(typeof(rs), Base.OneTo(0)) : rs
end

function _vcat_resizedata!(::Union{AbstractPaddedLayout, DualLayout{<:PaddedRows}}, B, m...)
any(iszero,m) || Base.checkbounds(paddeddata(B), m...)
B
end
function _vcat_resizedata!(::Union{DualLayout{<:PaddedRows}, AbstractPaddedLayout}, B::Vcat{<:Any, 1}, m) # ambiguity
iszero(m) || Base.checkbounds(paddeddata(B), m)
B
end

function _vcat_resizedata!(_, B::Vcat{<:Any, 1}, n)
resizedata!_layout(::Union{AbstractPaddedLayout, DualLayout{<:PaddedRows}}, B, m...) = B
function resizedata!_layout(::ApplyLayout{typeof(vcat)}, B::AbstractVector, n)
m = n
for arg in arguments(B)
m ≤ 0 && break
Expand All @@ -145,9 +137,6 @@ function _vcat_resizedata!(_, B::Vcat{<:Any, 1}, n)
B
end

_vcat_resizedata!(_, B, m...) = B # by default we can't resize

resizedata!(B::Vcat, m...) = _vcat_resizedata!(MemoryLayout(B), B, m...)

cacheddata(B::Vcat) = Vcat(map(maybe_cacheddata, arguments(B))...)

Expand Down
Loading