Defining a more forgiving conversion seems to solve all issues:
Base.convert(::Type{T}, x::Complex) where {T<:AbstractFloat} = abs(imag(x)) < 1e-16 ? T(real(x)) : throw(InexactError(nameof(T), T, x))
But taking the real part, or the norm instead of dot is probably more efficient.
Hi, came across an inexact error simulating with
mcwf_dynamic
;I think in this line I get very small imaginary parts from
dot(psi_new.data, psi_new.data)
https://github.com/qojulia/QuantumOptics.jl/blob/b2618ee33c9639617bcba11add5484052efa552b/src/mcwf.jl#L397Defining a more forgiving conversion seems to solve all issues:
Base.convert(::Type{T}, x::Complex) where {T<:AbstractFloat} = abs(imag(x)) < 1e-16 ? T(real(x)) : throw(InexactError(nameof(T), T, x))
But taking the
real
part, or thenorm
instead ofdot
is probably more efficient.I've put together a small example Pluto notebook, but seems l can only upload the pdf: 🎈 kpo_mcwf_mwe.jl — Pluto.jl.pdf