Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/bunchkaufman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,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
Expand Down
4 changes: 2 additions & 2 deletions src/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions test/bunchkaufman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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