@@ -235,48 +235,55 @@ for V in spacelist
235235
236236 @constinferred normalize! (t)
237237
238- U, S, Vᴴ = @constinferred svd_trunc (t; trunc = notrunc ())
238+ U, S, Vᴴ, ϵ = @constinferred svd_trunc (t; trunc = notrunc ())
239239 @test U * S * Vᴴ ≈ t
240+ @test ϵ ≈ 0
240241 @test isisometric (U)
241242 @test isisometric (Vᴴ; side = :right )
242243
243244 trunc = truncrank (dim (domain (S)) ÷ 2 )
244- U1, S1, Vᴴ1 = @constinferred svd_trunc (t; trunc)
245+ U1, S1, Vᴴ1, ϵ1 = @constinferred svd_trunc (t; trunc)
245246 @test t * Vᴴ1' ≈ U1 * S1
246247 @test isisometric (U1)
247248 @test isisometric (Vᴴ1; side = :right )
249+ @test norm (t - U1 * S1 * Vᴴ1) ≈ ϵ1 atol = eps (real (T))^ (4 / 5 )
248250 @test dim (domain (S1)) <= trunc. howmany
249251
250252 λ = minimum (minimum, values (LinearAlgebra. diag (S1)))
251253 trunc = trunctol (; atol = λ - 10 eps (λ))
252- U2, S2, Vᴴ2 = @constinferred svd_trunc (t; trunc)
254+ U2, S2, Vᴴ2, ϵ2 = @constinferred svd_trunc (t; trunc)
253255 @test t * Vᴴ2' ≈ U2 * S2
254256 @test isisometric (U2)
255257 @test isisometric (Vᴴ2; side = :right )
258+ @test norm (t - U2 * S2 * Vᴴ2) ≈ ϵ2 atol = eps (real (T))^ (4 / 5 )
256259 @test minimum (minimum, values (LinearAlgebra. diag (S1))) >= λ
257260 @test U2 ≈ U1
258261 @test S2 ≈ S1
259262 @test Vᴴ2 ≈ Vᴴ1
263+ @test ϵ1 ≈ ϵ2
260264
261265 trunc = truncspace (space (S2, 1 ))
262- U3, S3, Vᴴ3 = @constinferred svd_trunc (t; trunc)
266+ U3, S3, Vᴴ3, ϵ3 = @constinferred svd_trunc (t; trunc)
263267 @test t * Vᴴ3' ≈ U3 * S3
264268 @test isisometric (U3)
265269 @test isisometric (Vᴴ3; side = :right )
270+ @test norm (t - U3 * S3 * Vᴴ3) ≈ ϵ3 atol = eps (real (T))^ (4 / 5 )
266271 @test space (S3, 1 ) ≾ space (S2, 1 )
267272
268- trunc = truncerror (; atol = 0.5 )
269- U4, S4, Vᴴ4 = @constinferred svd_trunc (t; trunc)
273+ trunc = truncerror (; atol = ϵ2 )
274+ U4, S4, Vᴴ4, ϵ4 = @constinferred svd_trunc (t; trunc)
270275 @test t * Vᴴ4' ≈ U4 * S4
271276 @test isisometric (U4)
272277 @test isisometric (Vᴴ4; side = :right )
273- @test norm (t - U4 * S4 * Vᴴ4) <= 0.5
278+ @test norm (t - U4 * S4 * Vᴴ4) ≈ ϵ4 atol = eps (real (T))^ (4 / 5 )
279+ @test ϵ4 ≤ ϵ2
274280
275281 trunc = truncrank (dim (domain (S)) ÷ 2 ) & trunctol (; atol = λ - 10 eps (λ))
276- U5, S5, Vᴴ5 = @constinferred svd_trunc (t; trunc)
282+ U5, S5, Vᴴ5, ϵ5 = @constinferred svd_trunc (t; trunc)
277283 @test t * Vᴴ5' ≈ U5 * S5
278284 @test isisometric (U5)
279285 @test isisometric (Vᴴ5; side = :right )
286+ @test norm (t - U5 * S5 * Vᴴ5) ≈ ϵ5 atol = eps (real (T))^ (4 / 5 )
280287 @test minimum (minimum, values (LinearAlgebra. diag (S5))) >= λ
281288 @test dim (domain (S5)) ≤ dim (domain (S)) ÷ 2
282289 end
0 commit comments