diff --git a/Project.toml b/Project.toml index ac9d246..8fd86fa 100644 --- a/Project.toml +++ b/Project.toml @@ -28,7 +28,7 @@ BlockArrays = "1.0" BlockBandedMatrices = "0.13" FillArrays = "1.0" InfiniteArrays = "0.15" -LazyArrays = "2.2.3" +LazyArrays = "2.8" MatrixFactorizations = "3.0" StaticArrays = "1.0" julia = "1.10" diff --git a/src/LazyBandedMatrices.jl b/src/LazyBandedMatrices.jl index ae6d15d..0439512 100644 --- a/src/LazyBandedMatrices.jl +++ b/src/LazyBandedMatrices.jl @@ -17,7 +17,7 @@ import ArrayLayouts: MemoryLayout, bidiagonallayout, bidiagonaluplo, diagonaldat materialize!, MulAdd, MatMulVecAdd import LazyArrays: ApplyLayout, AbstractPaddedLayout, PaddedLayout, PaddedColumns, BroadcastLayout, LazyArrayStyle, LazyLayout, arguments, call, tuple_type_memorylayouts, paddeddata, _broadcast_sub_arguments, resizedata!, - _cumsum, convexunion, applylayout, AbstractLazyBandedLayout, ApplyBandedLayout, BroadcastBandedLayout, LazyBandedLayout + _cumsum, convexunion, applylayout, AbstractLazyBandedLayout, ApplyBandedLayout, BroadcastBandedLayout, LazyBandedLayout, applied_eltype import BandedMatrices: AbstractBandedMatrix, BandedStyle, bandwidths, isbanded import BlockBandedMatrices: AbstractBlockBandedLayout, AbstractBandedBlockBandedLayout, BlockRange1, Block1, blockbandwidths, subblockbandwidths, BlockBandedStyle, BandedBlockBandedStyle, isblockbanded, isbandedblockbanded @@ -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 @@ -34,6 +35,8 @@ const AbstractLazyBandedBlockBandedLayout = LazyArraysBlockBandedMatricesExt.Abs const ApplyBandedBlockBandedLayout = LazyArraysBlockBandedMatricesExt.ApplyBandedBlockBandedLayout const LazyBlockBandedLayouts = LazyArraysBlockBandedMatricesExt.LazyBlockBandedLayouts +const BlockVec = LazyArraysBlockArraysExt.BlockVec + export DiagTrav, KronTrav, blockkron, BlockKron, BlockBroadcastArray, BlockVcat, BlockHcat, BlockHvcat, unitblocks diff --git a/src/blockconcat.jl b/src/blockconcat.jl index 2695cd5..1466dac 100644 --- a/src/blockconcat.jl +++ b/src/blockconcat.jl @@ -488,28 +488,6 @@ MemoryLayout(::Type{BlockBroadcastArray{T,N,FF,Args}}) where {T,N,FF,Args} = blo resize!(c::BlockBroadcastVector{T,typeof(vcat)}, N::Block{1}) where T = BlockBroadcastVector{T}(vcat, resize!.(c.args, N)...) -#### -# 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])) diff --git a/test/test_blockconcat.jl b/test/test_blockconcat.jl index 64e56a8..86b0909 100644 --- a/test/test_blockconcat.jl +++ b/test/test_blockconcat.jl @@ -421,35 +421,4 @@ end end end -@testset "BlockVec" begin - X = randn(5,4) - b = BlockVec(X) - @test size(b) == (20,) - @test length(b) == 20 - @test MemoryLayout(b) isa ApplyLayout{typeof(blockvec)} - @test b == vec(X) - @test view(b, Block(3)) ≡ view(X, :, 3) - @test b[Block(3)] isa Vector - b[5] = 6 - @test X[5] == 6 - @test resize!(b, Block(2)) == b[Block.(1:2)] - - c = BlockVec(X') - @test c == vec(X') - @test view(c, Block(3)) ≡ view(X', :, 3) - @test resize!(c, Block(2)) == c[Block.(1:2)] - - c = BlockVec(transpose(X)) - @test c == vec(transpose(X)) - @test view(c, Block(3)) ≡ view(transpose(X), :, 3) - @test resize!(c, Block(2)) == c[Block.(1:2)] - - X = cache(Zeros(5,6)); - X[1,1] = 2 - c = BlockVec(X); - @test MemoryLayout(c) isa PaddedColumns - @test paddeddata(c) isa BlockVec - @test paddeddata(c) == [2] -end - end # module