Skip to content

Commit

Permalink
Make entropy_vn type-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgang-n authored and david-pl committed Sep 10, 2019
1 parent d0c0e63 commit 956d869
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/metrics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ natural logarithm and ``0\\log(0) ≡ 0``.
* `tol=1e-15`: Tolerance for rounding errors in the computed eigenvalues.
"""
function entropy_vn(rho::DenseOperator{B,B}; tol::Float64=1e-15) where B<:Basis
evals = eigvals(rho.data)
evals[abs.(evals) .< tol] .= 0.0
sum([d == 0 ? 0 : -d*log(d) for d=evals])
evals::Vector{ComplexF64} = eigvals(rho.data)
evals[abs.(evals) .< tol] .= 0.0im
sum([d == 0.0im ? 0.0im : -d*log(d) for d=evals])
end
entropy_vn(psi::StateVector; kwargs...) = entropy_vn(dm(psi); kwargs...)

Expand Down

0 comments on commit 956d869

Please sign in to comment.