From e1f057188447a6477c64f011fa0c84b23fe02d78 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Fri, 20 Jun 2025 13:24:43 +0530 Subject: [PATCH 1/2] Generic fallback for `fillstored!` --- src/adjtrans.jl | 5 +++++ src/dense.jl | 2 ++ test/adjtrans.jl | 11 +++++++++++ 3 files changed, 18 insertions(+) diff --git a/src/adjtrans.jl b/src/adjtrans.jl index c4de7dae..6d5e83ce 100644 --- a/src/adjtrans.jl +++ b/src/adjtrans.jl @@ -576,3 +576,8 @@ diagview(A::Adjoint, k::Integer = 0) = _vecadjoint(diagview(parent(A), -k)) # triu and tril triu!(A::AdjOrTransAbsMat, k::Integer = 0) = wrapperop(A)(tril!(parent(A), -k)) tril!(A::AdjOrTransAbsMat, k::Integer = 0) = wrapperop(A)(triu!(parent(A), -k)) + +function fillstored!(A::AdjOrTransAbsMat, v) + fillstored!(parent(A), wrapperop(A)(v)) + return A +end diff --git a/src/dense.jl b/src/dense.jl index eb9cdc83..6fade321 100644 --- a/src/dense.jl +++ b/src/dense.jl @@ -218,6 +218,8 @@ function fillband!(A::AbstractMatrix{T}, x, l, u) where T return A end +fillstored!(A::AbstractMatrix, v) = fill!(A, v) + diagind(m::Integer, n::Integer, k::Integer=0) = diagind(IndexLinear(), m, n, k) diagind(::IndexLinear, m::Integer, n::Integer, k::Integer=0) = k <= 0 ? range(1-k, step=m+1, length=min(m+k, n)) : range(k*m+1, step=m+1, length=min(m, n-k)) diff --git a/test/adjtrans.jl b/test/adjtrans.jl index 43868162..7bd9fcca 100644 --- a/test/adjtrans.jl +++ b/test/adjtrans.jl @@ -809,4 +809,15 @@ end end end +@testset "fillstored!" begin + A = rand(ComplexF64, 4, 4) + U = UpperTriangular(A) + @testset for op in (adjoint, transpose) + @test LinearAlgebra.fillstored!(op(A), 1) == op(fill(1, size(A))) + @test LinearAlgebra.fillstored!(op(A), 2im) == op(fill(op(2im), size(A))) + @test LinearAlgebra.fillstored!(op(U), 1) == op(triu(fill(1, size(U)))) + @test LinearAlgebra.fillstored!(op(U), 2im) == op(triu(fill(op(2im), size(U)))) + end +end + end # module TestAdjointTranspose From 129e29f8942d22e3a1061131ce90c7fc0c0d618c Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Fri, 20 Jun 2025 13:29:07 +0530 Subject: [PATCH 2/2] Test wrappers explicitly --- test/adjtrans.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/adjtrans.jl b/test/adjtrans.jl index 7bd9fcca..7a2eb62c 100644 --- a/test/adjtrans.jl +++ b/test/adjtrans.jl @@ -812,11 +812,11 @@ end @testset "fillstored!" begin A = rand(ComplexF64, 4, 4) U = UpperTriangular(A) - @testset for op in (adjoint, transpose) + @testset for (op, f) in ((Adjoint, adjoint), (Transpose, transpose)) @test LinearAlgebra.fillstored!(op(A), 1) == op(fill(1, size(A))) - @test LinearAlgebra.fillstored!(op(A), 2im) == op(fill(op(2im), size(A))) + @test LinearAlgebra.fillstored!(op(A), 2im) == op(fill(f(2im), size(A))) @test LinearAlgebra.fillstored!(op(U), 1) == op(triu(fill(1, size(U)))) - @test LinearAlgebra.fillstored!(op(U), 2im) == op(triu(fill(op(2im), size(U)))) + @test LinearAlgebra.fillstored!(op(U), 2im) == op(triu(fill(f(2im), size(U)))) end end