From c7fec580a7962b20294ad0986fc98954313f26bb Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Thu, 17 Apr 2025 19:29:35 +0530 Subject: [PATCH] Specialize `unaliascopy` for a `BandedMatrix` --- src/banded/BandedMatrix.jl | 4 ++++ test/test_banded.jl | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/banded/BandedMatrix.jl b/src/banded/BandedMatrix.jl index d2d8bd7f..94dd21ad 100644 --- a/src/banded/BandedMatrix.jl +++ b/src/banded/BandedMatrix.jl @@ -1032,3 +1032,7 @@ function one(A::BandedMatrix) m==n || throw(DimensionMismatch("multiplicative identity defined only for square matrices")) typeof(A)(I, (m,n)) end + +function Base.unaliascopy(B::BandedMatrix) + _BandedMatrix(Base.unaliascopy(B.data), Base.unaliascopy(B.raxis), B.l, B.u) +end diff --git a/test/test_banded.jl b/test/test_banded.jl index b718ad36..429c3477 100644 --- a/test/test_banded.jl +++ b/test/test_banded.jl @@ -586,6 +586,13 @@ include("mymatrix.jl") @test Q == I(5) @test eltype(Q) == Float64 end + + @testset "unaliascopy" begin + B = BandedMatrices._BandedMatrix(view(randn(1, 5),:,:), 5, 0, 0) + B2 = Base.unaliascopy(B) + @test B2 == B + @test typeof(B2) == typeof(B) + end end end # module