|
| 1 | +using Test |
| 2 | +using TestExtras |
| 3 | +using TensorKit |
| 4 | +using BlockTensorKit |
| 5 | +using Random |
| 6 | + |
| 7 | +Random.seed!(1234) |
| 8 | + |
| 9 | +@testset "BraidingTensor with SumSpace: $(sectortype(V))" for V in ( |
| 10 | + ℂ^2, Vect[Z2Irrep](0 => 1, 1 => 1), Vect[FibonacciAnyon](:I => 1, :τ => 1), |
| 11 | + ) |
| 12 | + V1, V2 = V, V ⊕ V # V1 != V2 to test adjoint |
| 13 | + S1, S2 = SumSpace(V1), SumSpace(V2) |
| 14 | + τ = @constinferred BraidingTensor(S1, S2) |
| 15 | + |
| 16 | + @test codomain(τ) == S2 ⊗ S1 |
| 17 | + @test domain(τ) == S1 ⊗ S2 |
| 18 | + @test TensorMap(τ[1, 1, 1, 1]) ≈ TensorMap(BraidingTensor(V1, V2)) |
| 19 | + |
| 20 | + t = TensorMap(τ) |
| 21 | + @test t' * t ≈ id(domain(t)) |
| 22 | + τ_adj = @constinferred BraidingTensor(S1, S2, true) |
| 23 | + @test codomain(τ_adj) == S1 ⊗ S2 |
| 24 | + @test domain(τ_adj) == S2 ⊗ S1 |
| 25 | + @test TensorMap(τ_adj) ≈ t' |
| 26 | + |
| 27 | + # agree with TensorKit's `braid` |
| 28 | + Sa, Sb, W = SumSpace(V1, V2), SumSpace(V2), SumSpace(V1) |
| 29 | + x = randn(ComplexF64, Sa ⊗ Sb, W) |
| 30 | + τm = @constinferred BraidingTensor(Sa, Sb) |
| 31 | + @plansor y[-1 -2; -3] := τm[-1 -2; 1 2] * x[1 2; -3] |
| 32 | + @test y ≈ braid(x, ((2, 1), (3,)), (1, 2, 3)) |
| 33 | + if !(BraidingStyle(sectortype(V)) isa SymmetricBraiding) |
| 34 | + @test !(y ≈ braid(x, ((2, 1), (3,)), (2, 1, 3))) |
| 35 | + end |
| 36 | +end |
0 commit comments