Skip to content

Commit 68deb82

Browse files
authored
Support move of BlockVec to LazyArrays (#150)
* Support move of BlockVec to LazyArrays * Update blockconcat.jl
1 parent 33fdfc4 commit 68deb82

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LazyBandedMatrices"
22
uuid = "d7e5e226-e90b-4449-9968-0f923699bf6f"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.11.5"
4+
version = "0.11.6"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/LazyBandedMatrices.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import BlockArrays: BlockSlices, BlockSlice1, BlockSlice, blockvec, AbstractBloc
2525
import FillArrays: SquareEye
2626

2727
const LazyArraysBlockBandedMatricesExt = Base.get_extension(LazyArrays, :LazyArraysBlockBandedMatricesExt)
28+
const LazyArraysBlockArraysExt = Base.get_extension(LazyArrays, :LazyArraysBlockArraysExt)
2829

2930
const AbstractLazyBlockBandedLayout = LazyArraysBlockBandedMatricesExt.AbstractLazyBlockBandedLayout
3031
const BroadcastBandedBlockBandedLayout = LazyArraysBlockBandedMatricesExt.BroadcastBandedBlockBandedLayout

src/blockconcat.jl

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -492,25 +492,29 @@ resize!(c::BlockBroadcastVector{T,typeof(vcat)}, N::Block{1}) where T = BlockBro
492492
# BlockVec
493493
####
494494

495-
const BlockVec{T, M<:AbstractMatrix{T}} = ApplyVector{T, typeof(blockvec), <:Tuple{M}}
496-
497-
BlockVec{T}(M::AbstractMatrix{T}) where T = ApplyVector{T}(blockvec, M)
498-
BlockVec(M::AbstractMatrix{T}) where T = BlockVec{T}(M)
499-
axes(b::BlockVec) = (blockedrange(Fill(size(b.args[1])...)),)
500-
size(b::BlockVec) = (length(b.args[1]),)
501-
502-
view(b::BlockVec, K::Block{1}) = view(b.args[1], :, Int(K))
503-
Base.@propagate_inbounds getindex(b::BlockVec, k::Int) = b.args[1][k]
504-
Base.@propagate_inbounds setindex!(b::BlockVec, v, k::Int) = setindex!(b.args[1], v, k)
505-
506-
_resize!(A::AbstractMatrix, m, n) = A[1:m, 1:n]
507-
_resize!(At::Transpose, m, n) = transpose(transpose(At)[1:n, 1:m])
508-
_resize!(Ac::Adjoint, m, n) = (Ac')[1:n, 1:m]'
509-
resize!(b::BlockVec, K::Block{1}) = BlockVec(_resize!(b.args[1], size(b.args[1],1), Int(K)))
510-
511-
applylayout(::Type{typeof(blockvec)}, ::AbstractPaddedLayout) = PaddedColumns{ApplyLayout{typeof(blockvec)}}()
512-
paddeddata(b::BlockVec) = BlockVec(paddeddata(b.args[1]))
513-
495+
# support LazyArrays v2.8 where BlockVec is moved
496+
if isdefined(LazyBandedMatrices.LazyArraysBlockArraysExt, :BlockVec)
497+
const BlockVec = LazyBandedMatrices.LazyArraysBlockArraysExt.BlockVec
498+
else
499+
const BlockVec{T, M<:AbstractMatrix{T}} = ApplyVector{T, typeof(blockvec), <:Tuple{M}}
500+
501+
BlockVec{T}(M::AbstractMatrix{T}) where T = ApplyVector{T}(blockvec, M)
502+
BlockVec(M::AbstractMatrix{T}) where T = BlockVec{T}(M)
503+
axes(b::BlockVec) = (blockedrange(Fill(size(b.args[1])...)),)
504+
size(b::BlockVec) = (length(b.args[1]),)
505+
506+
view(b::BlockVec, K::Block{1}) = view(b.args[1], :, Int(K))
507+
Base.@propagate_inbounds getindex(b::BlockVec, k::Int) = b.args[1][k]
508+
Base.@propagate_inbounds setindex!(b::BlockVec, v, k::Int) = setindex!(b.args[1], v, k)
509+
510+
_resize!(A::AbstractMatrix, m, n) = A[1:m, 1:n]
511+
_resize!(At::Transpose, m, n) = transpose(transpose(At)[1:n, 1:m])
512+
_resize!(Ac::Adjoint, m, n) = (Ac')[1:n, 1:m]'
513+
resize!(b::BlockVec, K::Block{1}) = BlockVec(_resize!(b.args[1], size(b.args[1],1), Int(K)))
514+
515+
applylayout(::Type{typeof(blockvec)}, ::AbstractPaddedLayout) = PaddedColumns{ApplyLayout{typeof(blockvec)}}()
516+
paddeddata(b::BlockVec) = BlockVec(paddeddata(b.args[1]))
517+
end
514518

515519

516520
####

0 commit comments

Comments
 (0)