diff --git a/Project.toml b/Project.toml index 2c41f6a7..c44ff6ea 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "BandedMatrices" uuid = "aae01518-5342-5314-be14-df237901396f" -version = "1.5.0" +version = "1.6.0" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" diff --git a/src/banded/BandedMatrix.jl b/src/banded/BandedMatrix.jl index f829cf92..9e43ee33 100644 --- a/src/banded/BandedMatrix.jl +++ b/src/banded/BandedMatrix.jl @@ -29,6 +29,8 @@ end _BandedMatrix(data::AbstractMatrix, m::Integer, l, u) = _BandedMatrix(data, oneto(m), l, u) +Base.parent(B::BandedMatrix) = B.data + const DefaultBandedMatrix{T} = BandedMatrix{T,Matrix{T},OneTo{Int}} bandedcolumns(_) = BandedColumns{UnknownLayout}() diff --git a/test/test_banded.jl b/test/test_banded.jl index 3aab6951..b761e79e 100644 --- a/test/test_banded.jl +++ b/test/test_banded.jl @@ -66,6 +66,12 @@ Base.similar(::MyMatrix, ::Type{T}, m::Int, n::Int) where T = MyMatrix{T}(undef, @test BandedMatrix{Int64, typeof(matrix)}(matrix, (1, 1)).data isa typeof(matrix) @test_throws UndefRefError BandedMatrix{Vector{Float64}}(undef, (5,5), (1,1))[1,1] + @testset "parent" begin + A = zeros(3,5) + B = _BandedMatrix(A, 5, 1, 1) + @test parent(B) === A + end + @testset "Construction from Diagonal" begin D = Diagonal(1:4) B1 = BandedMatrix(D)