Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace hard-coded truncate! threshold with the epsilon value of the chain's eltype #220

Merged
merged 5 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Ansatz/Chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/Helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ 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(eltype) = eltype <: Real ? eps(eltype) : eps(first(eltype.parameters))
jofrevalles marked this conversation as resolved.
Show resolved Hide resolved
Loading