From 3b0bbc8f97ce1ee29d8dd773b52a217829add721 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Fri, 16 Aug 2024 11:32:50 +0530 Subject: [PATCH 1/2] Specialize LinearAlgebra.symmetric for AbstractFill --- src/fillalgebra.jl | 4 ++++ test/runtests.jl | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/fillalgebra.jl b/src/fillalgebra.jl index c17e46cd..c6ecf343 100644 --- a/src/fillalgebra.jl +++ b/src/fillalgebra.jl @@ -554,3 +554,7 @@ end triu(A::AbstractZerosMatrix, k::Integer=0) = A tril(A::AbstractZerosMatrix, k::Integer=0) = A + +# symmetric +LinearAlgebra.symmetric(F::AbstractFillMatrix{<:Number}, uplo::Symbol=:U) = F +LinearAlgebra.symmetric_type(::Type{T}) where {T<:AbstractFillMatrix{<:Number}} = T \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 62b4c2ab..2d7297aa 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2848,3 +2848,10 @@ end @test triu(Z, 2) === Z @test tril(Z, 2) === Z end + +@testset "symmetric" begin + for F in (Fill(3, 4, 4), Zeros(4,4), Ones(4,4)) + @test LinearAlgebra.symmetric(F) == F + @test LinearAlgebra.symmetric_type(typeof(F)) == typeof(F) + end +end From f66544bc4d26d9fa55b149ea9b21cdce55be7bbe Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Fri, 16 Aug 2024 11:34:41 +0530 Subject: [PATCH 2/2] EOF newline --- src/fillalgebra.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fillalgebra.jl b/src/fillalgebra.jl index c6ecf343..18ebb3db 100644 --- a/src/fillalgebra.jl +++ b/src/fillalgebra.jl @@ -557,4 +557,4 @@ tril(A::AbstractZerosMatrix, k::Integer=0) = A # symmetric LinearAlgebra.symmetric(F::AbstractFillMatrix{<:Number}, uplo::Symbol=:U) = F -LinearAlgebra.symmetric_type(::Type{T}) where {T<:AbstractFillMatrix{<:Number}} = T \ No newline at end of file +LinearAlgebra.symmetric_type(::Type{T}) where {T<:AbstractFillMatrix{<:Number}} = T