Skip to content

Commit

Permalink
Fix chol for Symmetric(A, :L). (#18142)
Browse files Browse the repository at this point in the history
(cherry picked from commit f3fe910)
  • Loading branch information
andreasnoack authored and tkelman committed Aug 29, 2016
1 parent 746cc0c commit c0da8be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions base/linalg/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function chol(A::Hermitian)
if A.uplo == 'U'
copy!(AA, A.data)
else
Base.ccopy!(AA, A.data)
Base.ctranspose!(AA, A.data)
end
chol!(Hermitian(AA, :U))
end
Expand All @@ -150,7 +150,7 @@ function chol{T<:Real,S<:AbstractMatrix}(A::Symmetric{T,S})
if A.uplo == 'U'
copy!(AA, A.data)
else
Base.ccopy!(AA, A.data)
Base.ctranspose!(AA, A.data)
end
chol!(Hermitian(AA, :U))
end
Expand Down
10 changes: 8 additions & 2 deletions test/linalg/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int)
a = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex(areal, aimg) : areal)
a2 = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex(a2real, a2img) : a2real)
apd = a'*a # symmetric positive-definite
apds = Symmetric(apd)

apds = Symmetric(apd)
apdsL = Symmetric(apd, :L)
ε = εa = eps(abs(float(one(eltya))))

@inferred cholfact(apd)
Expand Down Expand Up @@ -78,11 +80,15 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int)
@test tril(lapd.factors) capd[:L]
if eltya <: Real
capds = cholfact(apds)
lapds = cholfact(Symmetric(apds.data, :L))
lapds = cholfact(apdsL)
cl = chol(apdsL)
ls = lapds[:L]
@test ls*ls' apd
@test triu(capds.factors) lapds[:U]
@test tril(lapds.factors) capds[:L]
@test istriu(cl)
@test cl'cl apds
@test cl'cl apdsL
end

#pivoted upper Cholesky
Expand Down

0 comments on commit c0da8be

Please sign in to comment.