Skip to content

Commit

Permalink
Merge pull request #12715 from JuliaLang/ksh/choltest
Browse files Browse the repository at this point in the history
Fixed an error type and added test for chol
  • Loading branch information
andreasnoack committed Aug 20, 2015
2 parents bffa22f + f1c0fbc commit 7420be9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/linalg/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ end
function chol!(x::Number, uplo)
rx = real(x)
if rx != abs(x)
throw(DomainError("x must be positive semidefinite"))
throw(ArgumentError("x must be positive semidefinite"))
end
rxr = sqrt(rx)
convert(promote_type(typeof(x), typeof(rxr)), rxr)
Expand Down
7 changes: 7 additions & 0 deletions test/linalg/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ debug && println("(Automatic) upper Cholesky factor")
r = capd[:U]
κ = cond(apd, 1) #condition number

#getindex
@test_throws KeyError capd[:Z]

#Test error bound on reconstruction of matrix: LAWNS 14, Lemma 2.1
E = abs(apd - r'*r)
for i=1:n, j=1:n
Expand All @@ -65,6 +68,7 @@ debug && println("(Automatic) upper Cholesky factor")

apos = apd[1,1] # test chol(x::Number), needs x>0
@test_approx_eq cholfact(apos).factors apos
@test_throws ArgumentError chol(-one(eltya))

# test chol of 2x2 Strang matrix
S = convert(AbstractMatrix{eltya},full(SymTridiagonal([2,2],[-1])))
Expand All @@ -87,6 +91,9 @@ debug && println("pivoted Choleksy decomposition")
@test_approx_eq apd * inv(cpapd) eye(n)
end
@test_approx_eq full(cpapd) apd

#getindex
@test_throws KeyError cpapd[:Z]
end
end
end
Expand Down

0 comments on commit 7420be9

Please sign in to comment.