From 956d869ef03ab155337e2f9fa9b970eb639f87db Mon Sep 17 00:00:00 2001 From: wolfgang-n <33723682+wolfgang-n@users.noreply.github.com> Date: Mon, 9 Sep 2019 17:19:27 +0200 Subject: [PATCH] Make entropy_vn type-stable --- src/metrics.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/metrics.jl b/src/metrics.jl index 57b6023b..36c55dd1 100644 --- a/src/metrics.jl +++ b/src/metrics.jl @@ -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...)