Skip to content

Commit 1ebc0cb

Browse files
jishnubViralBShah
authored andcommitted
Generic fallback for fillstored! (#1389)
Also, specialize for `Adjoint`/`Transpose` to dispatch to the methods for the parent. The following works after this: ```julia julia> U = Adjoint(UpperTriangular(zeros(2,2))) 2×2 adjoint(::UpperTriangular{Float64, Matrix{Float64}}) with eltype Float64: 0.0 ⋅ 0.0 0.0 julia> LinearAlgebra.fillstored!(U, 3) 2×2 adjoint(::UpperTriangular{Float64, Matrix{Float64}}) with eltype Float64: 3.0 ⋅ 3.0 3.0 ``` --------- Co-authored-by: Viral B. Shah <[email protected]>
1 parent 24f5e21 commit 1ebc0cb

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/adjtrans.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,3 +560,8 @@ diagview(A::Adjoint, k::Integer = 0) = _vecadjoint(diagview(parent(A), -k))
560560
# triu and tril
561561
triu!(A::AdjOrTransAbsMat, k::Integer = 0) = wrapperop(A)(tril!(parent(A), -k))
562562
tril!(A::AdjOrTransAbsMat, k::Integer = 0) = wrapperop(A)(triu!(parent(A), -k))
563+
564+
function fillstored!(A::AdjOrTransAbsMat, v)
565+
fillstored!(parent(A), wrapperop(A)(v))
566+
return A
567+
end

src/dense.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ function fillband!(A::AbstractMatrix{T}, x, l, u) where T
218218
return A
219219
end
220220

221+
fillstored!(A::AbstractMatrix, v) = fill!(A, v)
222+
221223
diagind(m::Integer, n::Integer, k::Integer=0) = diagind(IndexLinear(), m, n, k)
222224
diagind(::IndexLinear, m::Integer, n::Integer, k::Integer=0) =
223225
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))

test/adjtrans.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,4 +771,15 @@ end
771771
end
772772
end
773773

774+
@testset "fillstored!" begin
775+
A = rand(ComplexF64, 4, 4)
776+
U = UpperTriangular(A)
777+
@testset for (op, f) in ((Adjoint, adjoint), (Transpose, transpose))
778+
@test LinearAlgebra.fillstored!(op(A), 1) == op(fill(1, size(A)))
779+
@test LinearAlgebra.fillstored!(op(A), 2im) == op(fill(f(2im), size(A)))
780+
@test LinearAlgebra.fillstored!(op(U), 1) == op(triu(fill(1, size(U))))
781+
@test LinearAlgebra.fillstored!(op(U), 2im) == op(triu(fill(f(2im), size(U))))
782+
end
783+
end
784+
774785
end # module TestAdjointTranspose

0 commit comments

Comments
 (0)