From d28cbcc9a627149f3f19ff9bca63800f5afde7c9 Mon Sep 17 00:00:00 2001 From: lkdvos Date: Fri, 30 Oct 2026 16:07:11 -0400 Subject: [PATCH] Add regression test for long-range SvdCut with identity components Compressing a FiniteMPOHamiltonian with a long-range interaction whose operators have non-zero trace lost precision geometrically with distance in v0.14.0 (#550). This was fixed by the canonical-form rewrite in #539; this test guards against regressions. Co-Authored-By: Claude Opus 5.5 --- test/algorithms/changebonds.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/algorithms/changebonds.jl b/test/algorithms/changebonds.jl index 93b894b84..4a3a3a3c8 100644 --- a/test/algorithms/changebonds.jl +++ b/test/algorithms/changebonds.jl @@ -247,6 +247,16 @@ end ψ = FiniteMPS(rand, ComplexF64, L, pspace, ℙ^4) @test expectation_value(ψ, H′) ≈ expectation_value(ψ, H) rtol = 1.0e-10 + + # operators with a non-zero trace lost precision geometrically with distance in v0.14.0 (#550) + pspace = ℂ^4 + L = 30 + n = TensorMap(ComplexF64[1 0 0 0; 0 0 0 0; 0 0 1 0; 0 0 0 0], pspace ← pspace) + H = FiniteMPOHamiltonian(fill(pspace, L), (5, 25) => n ⊗ n) + + H′ = changebonds(H, SvdCut(; trunc = trunctol(; rtol = 0.0))) + ψ = FiniteMPS(rand, ComplexF64, L, pspace, ℂ^8) + @test expectation_value(ψ, H′) ≈ expectation_value(ψ, H) rtol = 1.0e-10 end @testset "SvdCut on InfiniteMPOHamiltonian $(spacetype(pspace))" for (pspace, Dspace) in spacelist