@@ -5,8 +5,16 @@ diagspacelist = ((ℂ^4)', ℂ[Z2Irrep](0 => 2, 1 => 3),
55@testset " DiagonalTensor with domain $V " for V in diagspacelist
66 @timedtestset " Basic properties and algebra" begin
77 for T in (Float32, Float64, ComplexF32, ComplexF64, BigFloat)
8+ # constructors
89 t = @constinferred DiagonalTensorMap {T} (undef, V)
910 t = @constinferred DiagonalTensorMap (rand (T, reduceddim (V)), V)
11+ t2 = @constinferred DiagonalTensorMap {T} (undef, space (t))
12+ @test space (t2) == space (t)
13+ @test_throws ArgumentError DiagonalTensorMap {T} (undef, V^ 2 ← V)
14+ t2 = @constinferred DiagonalTensorMap {T} (undef, domain (t))
15+ @test space (t2) == space (t)
16+ @test_throws ArgumentError DiagonalTensorMap {T} (undef, V^ 2 )
17+ # properties
1018 @test @constinferred (hash (t)) == hash (deepcopy (t))
1119 @test scalartype (t) == T
1220 @test codomain (t) == ProductSpace (V)
@@ -135,6 +143,16 @@ diagspacelist = ((ℂ^4)', ℂ[Z2Irrep](0 => 2, 1 => 3),
135143 @test u / t1 ≈ u / TensorMap (t1)
136144 @test t1 * u' ≈ TensorMap (t1) * u'
137145 @test t1 \ u' ≈ TensorMap (t1) \ u'
146+
147+ t3 = rand (Float64, V ← V^ 2 )
148+ t4 = rand (ComplexF64, V ← V^ 2 )
149+ @test t1 * t3 ≈ lmul! (t1, copy (t3))
150+ @test t2 * t4 ≈ lmul! (t2, copy (t4))
151+
152+ t3 = rand (Float64, V^ 2 ← V)
153+ t4 = rand (ComplexF64, V^ 2 ← V)
154+ @test t3 * t1 ≈ rmul! (copy (t3), t1)
155+ @test t4 * t2 ≈ rmul! (copy (t4), t2)
138156 end
139157 @timedtestset " Tensor contraction" begin
140158 d = DiagonalTensorMap (rand (ComplexF64, reduceddim (V)), V)
@@ -175,6 +193,12 @@ diagspacelist = ((ℂ^4)', ℂ[Z2Irrep](0 => 2, 1 => 3),
175193 VdV2 = V2' * V2
176194 @test VdV2 ≈ one (VdV2)
177195 @test t2 * V2 ≈ V2 * D2
196+
197+ @test rank (D) ≈ rank (t)
198+ @test cond (D) ≈ cond (t)
199+ @test all (((s, t),) -> isapprox (s, t),
200+ zip (values (LinearAlgebra. eigvals (D)),
201+ values (LinearAlgebra. eigvals (t))))
178202 end
179203 @testset " leftorth with $alg " for alg in (TensorKit. QR (), TensorKit. QL ())
180204 Q, R = @constinferred leftorth (t; alg= alg)
@@ -201,6 +225,12 @@ diagspacelist = ((ℂ^4)', ℂ[Z2Irrep](0 => 2, 1 => 3),
201225 VdV = Vᴴ * Vᴴ'
202226 @test VdV ≈ one (VdV)
203227 @test U * S * Vᴴ ≈ t
228+
229+ @test rank (S) ≈ rank (t)
230+ @test cond (S) ≈ cond (t)
231+ @test all (((s, t),) -> isapprox (s, t),
232+ zip (values (LinearAlgebra. svdvals (S)),
233+ values (LinearAlgebra. svdvals (t))))
204234 end
205235 end
206236 end
0 commit comments