Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eliminate full from test/linalg/cholesky.jl #23891

Merged
merged 1 commit into from
Sep 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions test/linalg/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ using Base.LinAlg: BlasComplex, BlasFloat, BlasReal, QRPivoted, PosDefException
for i=1:n, j=1:n
@test E[i,j] <= (n+1)ε/(1-(n+1)ε)*real(sqrt(apd[i,i]*apd[j,j]))
end
E = abs.(apd - full(capd))
E = abs.(apd - Matrix(capd))
for i=1:n, j=1:n
@test E[i,j] <= (n+1)ε/(1-(n+1)ε)*real(sqrt(apd[i,i]*apd[j,j]))
end
Expand Down Expand Up @@ -100,16 +100,16 @@ using Base.LinAlg: BlasComplex, BlasFloat, BlasReal, QRPivoted, PosDefException
end

# test chol of 2x2 Strang matrix
S = convert(AbstractMatrix{eltya},full(SymTridiagonal([2,2],[-1])))
@test full(chol(S)) ≈ [2 -1; 0 sqrt(eltya(3))] / sqrt(eltya(2))
S = Matrix{eltya}(SymTridiagonal([2, 2], [-1]))
@test Matrix(chol(S)) ≈ [2 -1; 0 sqrt(eltya(3))] / sqrt(eltya(2))

# test extraction of factor and re-creating original matrix
if eltya <: Real
capds = cholfact(apds)
lapds = cholfact(apdsL)
cl = chol(apdsL)
ls = lapds[:L]
@test full(capds) ≈ full(lapds) ≈ apd
@test Matrix(capds) ≈ Matrix(lapds) ≈ apd
@test ls*ls' ≈ apd
@test triu(capds.factors) ≈ lapds[:U]
@test tril(lapds.factors) ≈ capds[:L]
Expand All @@ -121,7 +121,7 @@ using Base.LinAlg: BlasComplex, BlasFloat, BlasReal, QRPivoted, PosDefException
lapdh = cholfact(apdhL)
cl = chol(apdhL)
ls = lapdh[:L]
@test full(capdh) ≈ full(lapdh) ≈ apd
@test Matrix(capdh) ≈ Matrix(lapdh) ≈ apd
@test ls*ls' ≈ apd
@test triu(capdh.factors) ≈ lapdh[:U]
@test tril(lapdh.factors) ≈ capdh[:L]
Expand All @@ -140,12 +140,12 @@ using Base.LinAlg: BlasComplex, BlasFloat, BlasReal, QRPivoted, PosDefException
if isreal(apd)
@test apd*inv(cpapd) ≈ eye(n)
end
@test full(cpapd) ≈ apd
@test Matrix(cpapd) ≈ apd
#getindex
@test_throws KeyError cpapd[:Z]

@test size(cpapd) == size(apd)
@test full(copy(cpapd)) ≈ apd
@test Matrix(copy(cpapd)) ≈ apd
@test det(cpapd) ≈ det(apd)
@test logdet(cpapd) ≈ logdet(apd)
@test cpapd[:P]*cpapd[:L]*cpapd[:U]*cpapd[:P]' ≈ apd
Expand Down Expand Up @@ -192,9 +192,9 @@ end

@testset "Cholesky factor of Matrix with non-commutative elements, here 2x2-matrices" begin
X = Matrix{Float64}[0.1*rand(2,2) for i in 1:3, j = 1:3]
L = full(Base.LinAlg._chol!(X*X', LowerTriangular)[1])
U = full(Base.LinAlg._chol!(X*X', UpperTriangular)[1])
XX = full(X*X')
L = Matrix(Base.LinAlg._chol!(X*X', LowerTriangular)[1])
U = Matrix(Base.LinAlg._chol!(X*X', UpperTriangular)[1])
XX = Matrix(X*X')

@test sum(sum(norm, L*L' - XX)) < eps()
@test sum(sum(norm, U'*U - XX)) < eps()
Expand All @@ -209,8 +209,8 @@ end
A = randn(5,5)
end
A = convert(Matrix{elty}, A'A)
@test full(cholfact(A)[:L]) ≈ full(invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{LowerTriangular}}, copy(A), LowerTriangular)[1])
@test full(cholfact(A)[:U]) ≈ full(invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{UpperTriangular}}, copy(A), UpperTriangular)[1])
@test Matrix(cholfact(A)[:L]) ≈ Matrix(invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{LowerTriangular}}, copy(A), LowerTriangular)[1])
@test Matrix(cholfact(A)[:U]) ≈ Matrix(invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{UpperTriangular}}, copy(A), UpperTriangular)[1])
end
end

Expand Down