Skip to content

Commit 02aa1a0

Browse files
committed
fix factorization test spaces and tolerances
1 parent a65cc18 commit 02aa1a0

4 files changed

Lines changed: 27 additions & 22 deletions

File tree

test/factorizations/eig.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ for V in spacelist
1616
println("---------------------------------------")
1717
@timedtestset "Eigenvalue decompositions with symmetry: $Istr" verbose = true begin
1818
V1, V2, V3, V4, V5 = V
19-
W = V1 V2
19+
W = V1 V2 V3
20+
Vd = fuse(V1 V2)
2021

2122
@testset "Eigenvalue decomposition" begin
2223
for T in eltypes,
2324
t in (
2425
rand(T, V1, V1), rand(T, W, W), rand(T, W, W)',
25-
DiagonalTensorMap(rand(T, reduceddim(V1)), V1),
26+
DiagonalTensorMap(rand(T, reduceddim(Vd)), Vd),
2627
)
2728

2829
d, v = @constinferred eig_full(t)

test/factorizations/ortho.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ for V in spacelist
1616
println("---------------------------------------")
1717
@timedtestset "QR and LQ decompositions with symmetry: $Istr" verbose = true begin
1818
V1, V2, V3, V4, V5 = V
19-
W = V1 V2
19+
W = V1 V2 V3
20+
Vd = fuse(V1 V2)
2021

2122
@testset "QR decomposition" begin
2223
for T in eltypes,
2324
t in (
2425
rand(T, W, W), rand(T, W, W)',
2526
rand(T, (V1 V2 V3), (V4 V5)'), rand(T, (V1 V2 V3), (V4 V5)')',
2627
rand(T, (V1 V2)', (V3 V4 V5)), rand(T, (V1 V2)', (V3 V4 V5))',
27-
DiagonalTensorMap(rand(T, reduceddim(V1)), V1),
28+
DiagonalTensorMap(rand(T, reduceddim(Vd)), Vd),
2829
)
2930

3031
Q, R = @constinferred qr_full(t)
@@ -79,7 +80,7 @@ for V in spacelist
7980
rand(T, W, W), rand(T, W, W)',
8081
rand(T, (V1 V2), (V3 V4 V5)'), rand(T, (V1 V2), (V3 V4 V5)')',
8182
rand(T, (V1 V2 V3)', (V4 V5)), rand(T, (V1 V2 V3)', (V4 V5))',
82-
DiagonalTensorMap(rand(T, reduceddim(V1)), V1),
83+
DiagonalTensorMap(rand(T, reduceddim(Vd)), Vd),
8384
)
8485

8586
L, Q = @constinferred lq_full(t)

test/factorizations/projections.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ for V in spacelist
1616
println("---------------------------------------")
1717
@timedtestset "Projections with symmetry: $Istr" verbose = true begin
1818
V1, V2, V3, V4, V5 = V
19-
W = V1 V2
20-
19+
W = V1 V2 V3
20+
Vd = fuse(V1 V2)
21+
2122
@testset "Hermitian projections" begin
2223
for T in eltypes,
2324
t in (
2425
rand(T, V1, V1), rand(T, W, W), rand(T, W, W)',
25-
DiagonalTensorMap(rand(T, reduceddim(V1)), V1),
26+
DiagonalTensorMap(rand(T, reduceddim(Vd)), Vd),
2627
)
2728
normalize!(t)
2829
noisefactor = eps(real(T))^(3 / 4)

test/factorizations/svd.jl

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using Test, TestExtras
22
using TensorKit
33
using LinearAlgebra: LinearAlgebra
4-
using MatrixAlgebraKit: diagview
5-
4+
using MatrixAlgebraKit: defaulttol, diagview
65

76
spacelist = factorization_spacelist(fast_tests)
87

@@ -16,15 +15,16 @@ for V in spacelist
1615
println("---------------------------------------------------------------")
1716
@timedtestset "Singular value and polar decompositions with symmetry: $Istr" verbose = true begin
1817
V1, V2, V3, V4, V5 = V
19-
W = V1 V2
18+
W = V1 V2 V3
19+
Vd = fuse(V1 V2)
2020

2121
@testset "Condition number and rank" begin
2222
for T in eltypes,
2323
t in (
2424
rand(T, W, W), rand(T, W, W)',
2525
rand(T, (V1 V2 V3), (V4 V5)'), rand(T, (V1 V2)', (V3 V4 V5))',
2626
rand(T, (V1 V2), (V3 V4 V5)'), rand(T, (V1 V2 V3)', (V4 V5))',
27-
DiagonalTensorMap(rand(T, reduceddim(V1)), V1),
27+
DiagonalTensorMap(rand(T, reduceddim(Vd)), Vd),
2828
)
2929

3030
d1, d2 = dim(codomain(t)), dim(domain(t))
@@ -62,7 +62,7 @@ for V in spacelist
6262
rand(T, W, W),
6363
rand(T, (V1 V2 V3), (V4 V5)'),
6464
rand(T, (V1 V2)', (V3 V4 V5))',
65-
DiagonalTensorMap(rand(T, reduceddim(V1)), V1),
65+
DiagonalTensorMap(rand(T, reduceddim(Vd)), Vd),
6666
)
6767

6868
@assert domain(t) codomain(t)
@@ -81,7 +81,7 @@ for V in spacelist
8181
rand(T, W, W),
8282
rand(T, (V1 V2), (V3 V4 V5)'),
8383
rand(T, (V1 V2 V3)', (V4 V5))',
84-
DiagonalTensorMap(rand(T, reduceddim(V1)), V1),
84+
DiagonalTensorMap(rand(T, reduceddim(Vd)), Vd),
8585
)
8686

8787
@assert codomain(t) domain(t)
@@ -102,7 +102,7 @@ for V in spacelist
102102
rand(T, W, W), rand(T, W, W)',
103103
rand(T, (V1 V2 V3), (V4 V5)'), rand(T, (V1 V2)', (V3 V4 V5))',
104104
rand(T, (V1 V2), (V3 V4 V5)'), rand(T, (V1 V2 V3)', (V4 V5))',
105-
DiagonalTensorMap(rand(T, reduceddim(V1)), V1),
105+
DiagonalTensorMap(rand(T, reduceddim(Vd)), Vd),
106106
)
107107

108108
u, s, vᴴ = @constinferred svd_full(t)
@@ -131,21 +131,23 @@ for V in spacelist
131131
@test c * vᴴ t
132132
@test isisometric(vᴴ; side = :right)
133133

134+
atol = norm(t) * defaulttol(T) # tol used by `:svd` left_null/right_null
135+
134136
N = @constinferred left_null(t; alg = :svd)
135137
@test isisometric(N)
136-
@test norm(N' * t) 0 atol = 100 * eps(norm(t))
138+
@test norm(N' * t) 0 atol = atol
137139

138-
N = @constinferred left_null(t; trunc = (; atol = 100 * eps(norm(t))))
140+
N = @constinferred left_null(t; trunc = (; atol = 6 * atol))
139141
@test isisometric(N)
140-
@test norm(N' * t) 0 atol = 100 * eps(norm(t))
142+
@test norm(N' * t) 0 atol = 10 * atol
141143

142144
Nᴴ = @constinferred right_null(t; alg = :svd)
143145
@test isisometric(Nᴴ; side = :right)
144-
@test norm(t * Nᴴ') 0 atol = 100 * eps(norm(t))
146+
@test norm(t * Nᴴ') 0 atol = atol
145147

146-
Nᴴ = @constinferred right_null(t; trunc = (; atol = 100 * eps(norm(t))))
148+
Nᴴ = @constinferred right_null(t; trunc = (; atol = 6 * atol))
147149
@test isisometric(Nᴴ; side = :right)
148-
@test norm(t * Nᴴ') 0 atol = 100 * eps(norm(t))
150+
@test norm(t * Nᴴ') 0 atol = 10 * atol
149151
end
150152

151153
# empty tensor
@@ -167,7 +169,7 @@ for V in spacelist
167169
rand(T, W, W), rand(T, W, W)',
168170
rand(T, (V1 V2 V3), (V4 V5)'), rand(T, (V1 V2)', (V3 V4 V5))',
169171
rand(T, (V1 V2), (V3 V4 V5)'), rand(T, (V1 V2 V3)', (V4 V5))',
170-
DiagonalTensorMap(rand(T, reduceddim(V1)), V1),
172+
DiagonalTensorMap(rand(T, reduceddim(Vd)), Vd),
171173
)
172174

173175
@constinferred normalize!(t)

0 commit comments

Comments
 (0)