@@ -2,7 +2,6 @@ using Test, TestExtras
22using TensorKit
33using TensorOperations
44using LinearAlgebra: LinearAlgebra
5- using Zygote
65
76@testset " BugfixConvert" begin
87 v = randn (
4342 @test storagetype (t5) == Vector{Float64}
4443 tensorfree! (t2)
4544end
46-
47- # https://github.com/quantumkithub/TensorKit.jl/issues/201
48- @testset " Issue #201" begin
49- function f (A:: AbstractTensorMap )
50- U, S, V, = svd_compact (A)
51- return tr (S)
52- end
53- function f (A:: AbstractMatrix )
54- S = LinearAlgebra. svdvals (A)
55- return sum (S)
56- end
57- A₀ = randn (Z2Space (4 , 4 ) ← Z2Space (4 , 4 ))
58- grad1, = Zygote. gradient (f, A₀)
59- grad2, = Zygote. gradient (f, convert (Array, A₀))
60- @test convert (Array, grad1) ≈ grad2
61-
62- function g (A:: AbstractTensorMap )
63- U, S, V, = svd_compact (A)
64- return tr (U * V)
65- end
66- function g (A:: AbstractMatrix )
67- U, S, V, = LinearAlgebra. svd (A)
68- return tr (U * V' )
69- end
70- B₀ = randn (ComplexSpace (4 ) ← ComplexSpace (4 ))
71- grad3, = Zygote. gradient (g, B₀)
72- grad4, = Zygote. gradient (g, convert (Array, B₀))
73- @test convert (Array, grad3) ≈ grad4
74- end
75-
76- # https://github.com/quantumkithub/TensorKit.jl/issues/209
77- @testset " Issue #209" begin
78- function f (T, D)
79- @tensor T[1 , 4 , 1 , 3 ] * D[3 , 4 ]
80- end
81- V = Z2Space (2 , 2 )
82- D = DiagonalTensorMap (randn (4 ), V)
83- T = randn (V ⊗ V ← V ⊗ V)
84- g1, = Zygote. gradient (f, T, D)
85- g2, = Zygote. gradient (f, T, TensorMap (D))
86- @test g1 ≈ g2
87- end
0 commit comments