Skip to content

Commit

Permalink
RFC: check the info code on getproperty
Browse files Browse the repository at this point in the history
now that we have replaced e.g. chol(A) with cholesky(A).U we don't check for positive definiteness
anymore. This adds a check for that.
  • Loading branch information
fredrikekre authored and mbauman committed May 23, 2018
1 parent ebf1fd2 commit 7c7d23d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions stdlib/LinearAlgebra/src/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,13 @@ size(C::Union{Cholesky, CholeskyPivoted}, d::Integer) = size(C.factors, d)
function getproperty(C::Cholesky, d::Symbol)
Cfactors = getfield(C, :factors)
Cuplo = getfield(C, :uplo)
info = getfield(C, :info)
if d == :U
return UpperTriangular(Symbol(Cuplo) == d ? Cfactors : copy(Cfactors'))
return @assertposdef UpperTriangular(Symbol(Cuplo) == d ? Cfactors : copy(Cfactors')) info
elseif d == :L
return LowerTriangular(Symbol(Cuplo) == d ? Cfactors : copy(Cfactors'))
return @assertposdef LowerTriangular(Symbol(Cuplo) == d ? Cfactors : copy(Cfactors')) info
elseif d == :UL
return Symbol(Cuplo) == :U ? UpperTriangular(Cfactors) : LowerTriangular(Cfactors)
return @assertposdef (Symbol(Cuplo) == :U ? UpperTriangular(Cfactors) : LowerTriangular(Cfactors)) info
else
return getfield(C, d)
end
Expand All @@ -334,12 +335,16 @@ function getproperty(C::CholeskyPivoted{T}, d::Symbol) where T<:BlasFloat
Cfactors = getfield(C, :factors)
Cuplo = getfield(C, :uplo)
if d == :U
chkfullrank(C)
return UpperTriangular(Symbol(Cuplo) == d ? Cfactors : copy(Cfactors'))
elseif d == :L
chkfullrank(C)
return LowerTriangular(Symbol(Cuplo) == d ? Cfactors : copy(Cfactors'))
elseif d == :p
chkfullrank(C)
return getfield(C, :piv)
elseif d == :P
chkfullrank(C)
n = size(C, 1)
P = zeros(T, n, n)
for i = 1:n
Expand Down

0 comments on commit 7c7d23d

Please sign in to comment.