Skip to content

Commit

Permalink
Added tests to LAPACK
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt authored and fcard committed Jul 8, 2015
1 parent 8dde214 commit 0065cee
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions test/linalg/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ for elty in (Float32, Float64, Complex64, Complex128)
@test_approx_eq b c
end

#sytri and sytrf
for elty in (Float32, Float64, Complex64, Complex128)
A = rand(elty,10,10)
A = A + A.' #symmetric!
B = copy(A)
B,ipiv = LAPACK.sytrf!('U',B)
@test_approx_eq triu(inv(A)) triu(LAPACK.sytri!('U',B,ipiv))
end

#trtri
for elty in (Float32, Float64, Complex64, Complex128)
A = rand(elty,10,10)
A = triu(A)
B = copy(A)
@test_approx_eq inv(A) LAPACK.trtri!('U','N',B)
end

#sysv
for elty in (Float32, Float64, Complex64, Complex128)
A = rand(elty,10,10)
Expand All @@ -121,3 +138,50 @@ for elty in (Complex64, Complex128)
b,A = LAPACK.hesv!('U',A,b)
@test_approx_eq b c
end

#ptsv
for elty in (Float32, Float64, Complex64, Complex128)
dv = real(ones(elty,10))
ev = zeros(elty,9)
A = SymTridiagonal(dv,ev)
if elty <: Complex
A = Tridiagonal(conj(ev),dv,ev)
end
B = rand(elty,10,10)
C = copy(B)
@test_approx_eq A\B LAPACK.ptsv!(dv,ev,C)
end

#pttrf and pttrs
for elty in (Float32, Float64, Complex64, Complex128)
dv = real(ones(elty,10))
ev = zeros(elty,9)
A = SymTridiagonal(dv,ev)
if elty <: Complex
A = Tridiagonal(conj(ev),dv,ev)
end
dv,ev = LAPACK.pttrf!(dv,ev)
B = rand(elty,10,10)
C = copy(B)
if elty <: Complex
@test_approx_eq A\B LAPACK.pttrs!('U',dv,ev,C)
else
@test_approx_eq A\B LAPACK.pttrs!(dv,ev,C)
end
end

#posv
for elty in (Float32, Float64, Complex64, Complex128)
A = rand(elty,10,10)
A += real(diagm(10*real(rand(elty,10))))
if elty <: Complex
A = A + A'
else
A = A + A.'
end
B = rand(elty,10,10)
D = copy(A)
C = copy(B)
D,C = LAPACK.posv!('U',D,C)
@test_approx_eq A\B C
end

0 comments on commit 0065cee

Please sign in to comment.