diff --git a/src/adjtrans.jl b/src/adjtrans.jl index ee610be7..89ece72a 100644 --- a/src/adjtrans.jl +++ b/src/adjtrans.jl @@ -560,3 +560,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/bunchkaufman.jl b/src/bunchkaufman.jl index a44f1a1c..07c3cdf4 100644 --- a/src/bunchkaufman.jl +++ b/src/bunchkaufman.jl @@ -215,6 +215,12 @@ BunchKaufman{T}(B::BunchKaufman) where {T} = BunchKaufman(convert(Matrix{T}, B.LD), B.ipiv, B.uplo, B.symmetric, B.rook, B.info) Factorization{T}(B::BunchKaufman) where {T} = BunchKaufman{T}(B) +AbstractMatrix(B::BunchKaufman) = B.uplo == 'U' ? B.P'B.U*B.D*B.U'B.P : B.P'B.L*B.D*B.L'B.P +AbstractArray(B::BunchKaufman) = AbstractMatrix(B) +Matrix(B::BunchKaufman) = convert(Array, AbstractArray(B)) +Array(B::BunchKaufman) = Matrix(B) + + size(B::BunchKaufman) = size(getfield(B, :LD)) size(B::BunchKaufman, d::Integer) = size(getfield(B, :LD), d) issymmetric(B::BunchKaufman) = B.symmetric diff --git a/src/cholesky.jl b/src/cholesky.jl index 2952503e..42550297 100644 --- a/src/cholesky.jl +++ b/src/cholesky.jl @@ -646,7 +646,7 @@ Factorization{T}(C::CholeskyPivoted) where {T} = CholeskyPivoted{T}(C) AbstractMatrix(C::Cholesky) = C.uplo == 'U' ? C.U'C.U : C.L*C.L' AbstractArray(C::Cholesky) = AbstractMatrix(C) -Matrix(C::Cholesky) = Array(AbstractArray(C)) +Matrix(C::Cholesky) = convert(Array, AbstractArray(C)) Array(C::Cholesky) = Matrix(C) function AbstractMatrix(F::CholeskyPivoted) @@ -655,7 +655,7 @@ function AbstractMatrix(F::CholeskyPivoted) U'U end AbstractArray(F::CholeskyPivoted) = AbstractMatrix(F) -Matrix(F::CholeskyPivoted) = Array(AbstractArray(F)) +Matrix(F::CholeskyPivoted) = convert(Array, AbstractArray(F)) Array(F::CholeskyPivoted) = Matrix(F) copy(C::Cholesky) = Cholesky(copy(C.factors), C.uplo, C.info) diff --git a/src/dense.jl b/src/dense.jl index 234b1022..9621e115 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 e5654004..371230b9 100644 --- a/test/adjtrans.jl +++ b/test/adjtrans.jl @@ -771,4 +771,15 @@ end end end +@testset "fillstored!" begin + A = rand(ComplexF64, 4, 4) + U = UpperTriangular(A) + @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(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(f(2im), size(U)))) + end +end + end # module TestAdjointTranspose diff --git a/test/bunchkaufman.jl b/test/bunchkaufman.jl index cf4fa488..3e3e0d71 100644 --- a/test/bunchkaufman.jl +++ b/test/bunchkaufman.jl @@ -259,4 +259,13 @@ end @test B.U * B.D * B.U' ≈ S end +@testset "BunchKaufman array constructors #1461" begin + a = randn(5,5) + A = a'a + for ul in (:U, :L) + B = bunchkaufman(Symmetric(A, ul)) + @test A ≈ Array(B) ≈ Matrix(B) ≈ AbstractArray(B) ≈ AbstractMatrix(B) + end +end + end # module TestBunchKaufman