Skip to content

Commit 0ab6085

Browse files
jishnublazarusA
authored andcommitted
Transpose triangular wrapper in Cholesky getproperty (JuliaLang#54491)
1 parent 61e8233 commit 0ab6085

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

stdlib/LinearAlgebra/src/cholesky.jl

+10-2
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,17 @@ function getproperty(C::Cholesky, d::Symbol)
519519
Cfactors = getfield(C, :factors)
520520
Cuplo = getfield(C, :uplo)
521521
if d === :U
522-
return UpperTriangular(Cuplo === char_uplo(d) ? Cfactors : copy(Cfactors'))
522+
if Cuplo === 'U'
523+
return UpperTriangular(Cfactors)
524+
else
525+
return copy(LowerTriangular(Cfactors)')
526+
end
523527
elseif d === :L
524-
return LowerTriangular(Cuplo === char_uplo(d) ? Cfactors : copy(Cfactors'))
528+
if Cuplo === 'L'
529+
return LowerTriangular(Cfactors)
530+
else
531+
return copy(UpperTriangular(Cfactors)')
532+
end
525533
elseif d === :UL
526534
return (Cuplo === 'U' ? UpperTriangular(Cfactors) : LowerTriangular(Cfactors))
527535
else

stdlib/LinearAlgebra/test/cholesky.jl

+10-1
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,15 @@ end
546546
@test det(B) det(A) atol=eps()
547547
@test logdet(B) == -Inf
548548
@test logabsdet(B)[1] == -Inf
549-
end
549+
end
550+
551+
@testset "partly initialized factors" begin
552+
@testset for uplo in ('U', 'L')
553+
M = Matrix{BigFloat}(undef, 2, 2)
554+
M[1,1] = M[2,2] = M[1+(uplo=='L'), 1+(uplo=='U')] = 3
555+
C = Cholesky(M, uplo, 0)
556+
@test C.L == C.U'
557+
end
558+
end
550559

551560
end # module TestCholesky

0 commit comments

Comments
 (0)