diff --git a/src/Ansatz/Chain.jl b/src/Ansatz/Chain.jl index bc7332728..72d80b237 100644 --- a/src/Ansatz/Chain.jl +++ b/src/Ansatz/Chain.jl @@ -393,7 +393,7 @@ function truncate!(qtn::Chain, bond; threshold::Union{Nothing,Real}=nothing, max # remove 0s from spectrum if isnothing(threshold) - threshold = 1e-16 + threshold = wrap_eps(eltype(qtn)) end filter!(extent) do i diff --git a/src/Helpers.jl b/src/Helpers.jl index e819032b0..05be5be6f 100644 --- a/src/Helpers.jl +++ b/src/Helpers.jl @@ -44,3 +44,8 @@ function nextindex!(gen::IndexCounter) return letter(Threads.atomic_add!(gen.counter, 1)) end resetindex!(gen::IndexCounter) = letter(Threads.atomic_xchg!(gen.counter, 1)) + +# eps wrapper so it handles Complex numbers +# if is Complex, extract the parametric type and get the eps of that +wrap_eps(x) = eps(x) +wrap_eps(::Type{Complex{T}}) where {T} = eps(T)