@@ -19,39 +19,43 @@ vspaces = (ℙ^10, Rep[U₁]((0 => 20)), Rep[SU₂](1 // 2 => 10, 3 // 2 => 5, 5
1919@testset " FiniteMPO" begin
2020 # start from random operators
2121 L = 4
22- O₁ = TensorMap (rand, ComplexF64, (ℂ^ 2 )^ L, (ℂ^ 2 )^ L)
23- O₂ = TensorMap (rand, ComplexF64, space (O₁))
22+ T = ComplexF64
2423
25- # create MPO and convert it back to see if it is the same
26- mpo₁ = FiniteMPO (O₁) # type-unstable for now!
27- mpo₂ = FiniteMPO (O₂)
28- @test convert (TensorMap, mpo₁) ≈ O₁
29- @test convert (TensorMap, - mpo₂) ≈ - O₂
24+ for V in (ℂ^ 2 , U1Space (0 => 1 , 1 => 1 ))
25+ O₁ = TensorMap (rand, T, V^ L, V^ L)
26+ O₂ = TensorMap (rand, T, space (O₁))
3027
31- # test scalar multiplication
32- α = rand (ComplexF64)
33- @test convert (TensorMap, α * mpo₁) ≈ α * O₁
34- @test convert (TensorMap, mpo₁ * α) ≈ O₁ * α
28+ # create MPO and convert it back to see if it is the same
29+ mpo₁ = FiniteMPO (O₁) # type-unstable for now!
30+ mpo₂ = FiniteMPO (O₂)
31+ @test convert (TensorMap, mpo₁) ≈ O₁
32+ @test convert (TensorMap, - mpo₂) ≈ - O₂
3533
36- # test addition and multiplication
37- @test convert (TensorMap, mpo₁ + mpo₂) ≈ O₁ + O₂
38- @test convert (TensorMap, mpo₁ * mpo₂) ≈ O₁ * O₂
34+ # test scalar multiplication
35+ α = rand (T)
36+ @test convert (TensorMap, α * mpo₁) ≈ α * O₁
37+ @test convert (TensorMap, mpo₁ * α) ≈ O₁ * α
3938
40- # test application to a state
41- ψ₁ = Tensor (rand, ComplexF64, domain (O₁))
42- mps₁ = FiniteMPS (ψ₁)
39+ # test addition and multiplication
40+ @test convert (TensorMap, mpo₁ + mpo₂) ≈ O₁ + O₂
41+ @test convert (TensorMap, mpo₁ * mpo₂) ≈ O₁ * O₂
4342
44- @test convert (TensorMap, mpo₁ * mps₁) ≈ O₁ * ψ₁
43+ # test application to a state
44+ ψ₁ = Tensor (rand, T, domain (O₁))
45+ mps₁ = FiniteMPS (ψ₁)
4546
46- @test dot (mps₁, mpo₁, mps₁) ≈ dot (ψ₁, O₁, ψ₁)
47- @test dot (mps₁, mpo₁, mps₁) ≈ dot (mps₁, mpo₁ * mps₁)
48- # test conversion to and from mps
49- mpomps₁ = convert (FiniteMPS, mpo₁)
50- mpompsmpo₁ = convert (FiniteMPO, mpomps₁)
47+ @test convert (TensorMap, mpo₁ * mps₁) ≈ O₁ * ψ₁
5148
52- @test convert (FiniteMPO, mpomps₁) ≈ mpo₁ rtol = 1e-6
49+ @test dot (mps₁, mpo₁, mps₁) ≈ dot (ψ₁, O₁, ψ₁)
50+ @test dot (mps₁, mpo₁, mps₁) ≈ dot (mps₁, mpo₁ * mps₁)
51+ # test conversion to and from mps
52+ mpomps₁ = convert (FiniteMPS, mpo₁)
53+ mpompsmpo₁ = convert (FiniteMPO, mpomps₁)
5354
54- @test dot (mpomps₁, mpomps₁) ≈ dot (mpo₁, mpo₁)
55+ @test convert (FiniteMPO, mpomps₁) ≈ mpo₁ rtol = 1e-6
56+
57+ @test dot (mpomps₁, mpomps₁) ≈ dot (mpo₁, mpo₁)
58+ end
5559end
5660
5761@testset " Finite MPOHamiltonian" begin
0 commit comments