Skip to content

Commit

Permalink
Merge pull request #119 from JuliaLinearAlgebra/vs/118
Browse files Browse the repository at this point in the history
Fix #118
  • Loading branch information
ViralBShah authored Dec 31, 2020
2 parents 4cb1b35 + d014b07 commit 7cfcbe3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Arpack"
uuid = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97"
version = "0.5.0"
version = "0.5.1"

[deps]
Arpack_jll = "68821587-b530-5797-8361-c406ea357684"
Expand All @@ -9,7 +9,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"

[compat]
Arpack_jll = "3.8"
Arpack_jll = "~3.5"
julia = "1.3"

[extras]
Expand Down
42 changes: 42 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,45 @@ let A = [1. 0. 0.; 0. 0. 0.; 0. 0. 0.]
@test U'U I
@test V'V I
end

# Problematic example from #118
@testset "issue 118" begin
ωc = 1.2
ωa = 0.9
γ = 0.5
κ = 1.1

sz = sparse(ComplexF64[1 0; 0 -1])
sp = sparse(ComplexF64[0 1; 0 0])
sm = sparse(collect(sp'))
ids = one(sz)

a = sparse(diagm(1 => ComplexF64[sqrt(i) for i=1:10]))
ida = one(a)

Ha = kron(ida, 0.5*ωa*sz)
Hc = kron(ωc*a'*a, ids)
Hint = sparse(kron(a', sm) + kron(a, sp))
H = Ha + Hc + Hint

Ja = kron(ida, sqrt(γ)*sm)
Jc = kron(sqrt(κ)*a, ids)
J = sqrt(2) .* [Ja, Jc]
Jdagger = adjoint.(J)
rates = 0.5 .* ones(length(J))

spre(x) = kron(one(x), x)
spost(x) = kron(permutedims(x), one(x))

L = spre(-1im*H) + spost(1im*H)
for i=1:length(J)
jdagger_j = rates[i]/2*Jdagger[i]*J[i]
L -= spre(jdagger_j) + spost(jdagger_j)
L += spre(rates[i]*J[i]) * spost(Jdagger[i])
end

for _=1:100
d, rest = eigs(L, nev=2, which=:LR)
@test abs(d[1]) < 1e-9
end
end

0 comments on commit 7cfcbe3

Please sign in to comment.