Skip to content

Commit

Permalink
Casting low-rank CholeskyPivoted to Matrix (#33775)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianAment authored and dkarrasch committed Nov 9, 2019
1 parent 8c34ad3 commit 7212602
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion stdlib/LinearAlgebra/src/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,8 @@ Array(C::Cholesky) = Matrix(C)

function AbstractMatrix(F::CholeskyPivoted)
ip = invperm(F.p)
(F.L * F.U)[ip,ip]
U = F.U[1:F.rank,ip]
U'U
end
AbstractArray(F::CholeskyPivoted) = AbstractMatrix(F)
Matrix(F::CholeskyPivoted) = Array(AbstractArray(F))
Expand Down
7 changes: 7 additions & 0 deletions stdlib/LinearAlgebra/test/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -392,4 +392,11 @@ end

end

@testset "issue #33704, casting low-rank CholeskyPivoted to Matrix" begin
A = randn(1,8)
B = A'A
C = cholesky(B, Val(true), check=false)
@test B Matrix(C)
end

end # module TestCholesky

0 comments on commit 7212602

Please sign in to comment.