Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matteoacrossi committed May 7, 2018
1 parent 11d11b9 commit 8bdc87f
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
using ExpmV
using Base.Test

for i = 1:20, d in 10:10:60, herm in [true, false]
r = sprandn(d,d,.1)+1im*sprandn(d,d,.1)
if herm
r = (r-r')/2
end

rv = randn(d)+1im*randn(d)
rv = rv / norm(rv,2)
@testset "Hermitian: $herm" for herm in [true, false]
@testset "Size: $d" for d in 10:10:60
for i = 1:20
r = sprandn(d,d,.1)+1im*sprandn(d,d,.1)
if herm
r = (r-r')/2
end

rt = randn()
rv = randn(d)+1im*randn(d)
rv = rv / norm(rv,2)

x = expmv(rt,r,rv)
@test norm(x-expm(full(rt*r))*rv,2) 0.0 atol=1.0e-9
rt = randn()

# Test the StepRangeLen version against the normal version

t = linspace(0, rt, 51)
x = expmv(t,r,rv)
y = hcat([expmv(ti,r,rv) for ti in t]...)
@test x y atol=1.0e-10
x = expmv(rt,r,rv)
@testset "Against expm" begin
@test norm(x-expm(full(rt*r))*rv,2) 0.0 atol=1.0e-9
end
# Test the StepRangeLen version against the normal version
@testset "Timespan $nt timesteps" for nt in [5 11 51]
t = linspace(0, rt, nt)
@time x = expmv(t,r,rv)
@time y = hcat([expmv(ti,r,rv) for ti in t]...)
@test x y atol=1.0e-10
end
end
end
end

0 comments on commit 8bdc87f

Please sign in to comment.