From 79d748bcee8ddf0990691a60cfa57e06cf14935a Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Wed, 14 Oct 2026 04:57:43 -0400 Subject: [PATCH] Make positive_approx more GPU friendly --- src/algorithms/contractions/bondenv/gaugefix.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/contractions/bondenv/gaugefix.jl b/src/algorithms/contractions/bondenv/gaugefix.jl index 3e6643325..19c982b35 100644 --- a/src/algorithms/contractions/bondenv/gaugefix.jl +++ b/src/algorithms/contractions/bondenv/gaugefix.jl @@ -21,9 +21,9 @@ function positive_approx(benv::AbstractTensorMap{T, S, N, N}) where {T, S, N} # If `benv` is negative (e.g. obtained approximately from CTMRG), # we can multiply it by (-1). data = D.data - @inbounds for i in eachindex(data) - d = (sgn == -1) ? -data[i] : data[i] - data[i] = (d > 0) ? sqrt(d) : zero(d) + map!(data, data) do d + d2 = (sgn < 0) ? -d : d + return (d2 > 0) ? sqrt(d2) : zero(d2) end Z = D * U' return Z