Skip to content

Commit 32cbf65

Browse files
committed
fix #314 (again)
1 parent d60855e commit 32cbf65

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/factorizations/truncation.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ end
145145
# Find truncation
146146
# ---------------
147147
# auxiliary functions
148-
rtol_to_atol(S, p, atol, rtol) =
149-
rtol == 0 ? atol : max(atol, TensorKit._norm(S, p, norm(zero(scalartype(valtype(S))))) * rtol)
148+
rtol_to_atol(S, p, atol, rtol) = rtol == 0 ? atol : max(atol, norm(S, p) * rtol)
150149

151150
function _compute_truncerr(Σdata, truncdim, p = 2)
152151
I = keytype(Σdata)

test/tensors/factorizations.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,14 @@ for V in spacelist
282282
@test norm(t - U3 * S3 * Vᴴ3) ϵ3 atol = eps(real(T))^(4 / 5)
283283
@test space(S3, 1) space(S2, 1)
284284

285-
trunc = truncerror(; atol = ϵ2)
286-
U4, S4, Vᴴ4, ϵ4 = @constinferred svd_trunc(t; trunc)
287-
@test t * Vᴴ4' U4 * S4
288-
@test isisometric(U4)
289-
@test isisometric(Vᴴ4; side = :right)
290-
@test norm(t - U4 * S4 * Vᴴ4) ϵ4 atol = eps(real(T))^(4 / 5)
291-
@test ϵ4 ϵ2
285+
for trunc in (truncerror(; atol = ϵ2), truncerror(; rtol = ϵ2 / norm(t)))
286+
U4, S4, Vᴴ4, ϵ4 = @constinferred svd_trunc(t; trunc)
287+
@test t * Vᴴ4' U4 * S4
288+
@test isisometric(U4)
289+
@test isisometric(Vᴴ4; side = :right)
290+
@test norm(t - U4 * S4 * Vᴴ4) ϵ4 atol = eps(real(T))^(4 / 5)
291+
@test ϵ4 ϵ2
292+
end
292293

293294
trunc = truncrank(nvals) & trunctol(; atol = λ - 10eps(λ))
294295
U5, S5, Vᴴ5, ϵ5 = @constinferred svd_trunc(t; trunc)

0 commit comments

Comments
 (0)