forked from marcusps/ExpmV.jl
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11d11b9
commit 8bdc87f
Showing
1 changed file
with
23 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |