diff --git a/Project.toml b/Project.toml index b2c9f70..d5dc809 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LazyBandedMatrices" uuid = "d7e5e226-e90b-4449-9968-0f923699bf6f" authors = ["Sheehan Olver "] -version = "0.11.5" +version = "0.11.6" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" diff --git a/src/LazyBandedMatrices.jl b/src/LazyBandedMatrices.jl index eb84084..f646986 100644 --- a/src/LazyBandedMatrices.jl +++ b/src/LazyBandedMatrices.jl @@ -25,6 +25,7 @@ import BlockArrays: BlockSlices, BlockSlice1, BlockSlice, blockvec, AbstractBloc import FillArrays: SquareEye const LazyArraysBlockBandedMatricesExt = Base.get_extension(LazyArrays, :LazyArraysBlockBandedMatricesExt) +const LazyArraysBlockArraysExt = Base.get_extension(LazyArrays, :LazyArraysBlockArraysExt) const AbstractLazyBlockBandedLayout = LazyArraysBlockBandedMatricesExt.AbstractLazyBlockBandedLayout const BroadcastBandedBlockBandedLayout = LazyArraysBlockBandedMatricesExt.BroadcastBandedBlockBandedLayout diff --git a/src/blockconcat.jl b/src/blockconcat.jl index 2695cd5..0146f3c 100644 --- a/src/blockconcat.jl +++ b/src/blockconcat.jl @@ -492,25 +492,29 @@ resize!(c::BlockBroadcastVector{T,typeof(vcat)}, N::Block{1}) where T = BlockBro # BlockVec #### -const BlockVec{T, M<:AbstractMatrix{T}} = ApplyVector{T, typeof(blockvec), <:Tuple{M}} - -BlockVec{T}(M::AbstractMatrix{T}) where T = ApplyVector{T}(blockvec, M) -BlockVec(M::AbstractMatrix{T}) where T = BlockVec{T}(M) -axes(b::BlockVec) = (blockedrange(Fill(size(b.args[1])...)),) -size(b::BlockVec) = (length(b.args[1]),) - -view(b::BlockVec, K::Block{1}) = view(b.args[1], :, Int(K)) -Base.@propagate_inbounds getindex(b::BlockVec, k::Int) = b.args[1][k] -Base.@propagate_inbounds setindex!(b::BlockVec, v, k::Int) = setindex!(b.args[1], v, k) - -_resize!(A::AbstractMatrix, m, n) = A[1:m, 1:n] -_resize!(At::Transpose, m, n) = transpose(transpose(At)[1:n, 1:m]) -_resize!(Ac::Adjoint, m, n) = (Ac')[1:n, 1:m]' -resize!(b::BlockVec, K::Block{1}) = BlockVec(_resize!(b.args[1], size(b.args[1],1), Int(K))) - -applylayout(::Type{typeof(blockvec)}, ::AbstractPaddedLayout) = PaddedColumns{ApplyLayout{typeof(blockvec)}}() -paddeddata(b::BlockVec) = BlockVec(paddeddata(b.args[1])) - +# support LazyArrays v2.8 where BlockVec is moved +if isdefined(LazyBandedMatrices.LazyArraysBlockArraysExt, :BlockVec) + const BlockVec = LazyBandedMatrices.LazyArraysBlockArraysExt.BlockVec +else + const BlockVec{T, M<:AbstractMatrix{T}} = ApplyVector{T, typeof(blockvec), <:Tuple{M}} + + BlockVec{T}(M::AbstractMatrix{T}) where T = ApplyVector{T}(blockvec, M) + BlockVec(M::AbstractMatrix{T}) where T = BlockVec{T}(M) + axes(b::BlockVec) = (blockedrange(Fill(size(b.args[1])...)),) + size(b::BlockVec) = (length(b.args[1]),) + + view(b::BlockVec, K::Block{1}) = view(b.args[1], :, Int(K)) + Base.@propagate_inbounds getindex(b::BlockVec, k::Int) = b.args[1][k] + Base.@propagate_inbounds setindex!(b::BlockVec, v, k::Int) = setindex!(b.args[1], v, k) + + _resize!(A::AbstractMatrix, m, n) = A[1:m, 1:n] + _resize!(At::Transpose, m, n) = transpose(transpose(At)[1:n, 1:m]) + _resize!(Ac::Adjoint, m, n) = (Ac')[1:n, 1:m]' + resize!(b::BlockVec, K::Block{1}) = BlockVec(_resize!(b.args[1], size(b.args[1],1), Int(K))) + + applylayout(::Type{typeof(blockvec)}, ::AbstractPaddedLayout) = PaddedColumns{ApplyLayout{typeof(blockvec)}}() + paddeddata(b::BlockVec) = BlockVec(paddeddata(b.args[1])) +end ####